[libc-commits] [libc] [libc] Add compile tests for each public header (PR #122527)
Roland McGrath via libc-commits
libc-commits at lists.llvm.org
Fri Jan 10 16:47:35 PST 2025
================
@@ -483,3 +483,69 @@ add_libc_test(
DEPENDS
libc.include.llvm-libc-macros.math_function_macros
)
+
+# Test `#include <...>` of each header in each available language mode.
+# This is gated on -DLLVM_LIBC_BUILD_HEADER_TESTS=ON until all the bugs
+# in headers are fixed so the tests all compile.
+set(TEST_STDC_VERSIONS 89;99;11;17;23)
+set(TEST_STDCXX_VERSIONS 03;11;14;17;20;23;26)
+
+function(add_header_test target_name source_file deps std_mode)
+ if(LLVM_LIBC_BUILD_HEADER_TESTS)
+ add_libc_test(
+ ${target_name}
+ C_TEST
+ HERMETIC_TEST_ONLY
+ SUITE
+ libc_include_tests
+ SRCS
+ ${source_file}
+ COMPILE_OPTIONS
+ -Werror
+ -Wall
+ -Wextra
----------------
frobtech wrote:
I don't think we need to, but it shouldn't hurt. I'll try it.
These will only be considered "system headers" by the compiler if they're found in a directory that's put on the path with `-isystem` rather than `-I` or `-idirafter` or anything else. AFAICT we use `-isystem` for the clang headers (the ones copied from `clang/lib/Headers`) but not for our own. So if I'm right, then using `-Wsystem-headers` here will only make things fail if the *clang* headers are not warning-clean, not the libc headers. (I personally am a big fan of thorough warning-clean behavior and `-Wsystem-headers`, but many headers both in OS installs and perhaps clang and libc++ headers are not actually warning clean in my experience, unfortunately.) For the libc headers, `-idirafter` is actually the right thing to be using IMHO. But it only really matters to use that instead of `-I` if you're using toolchain-supplied libc++ headers, which the libc cmake build does not.
https://github.com/llvm/llvm-project/pull/122527
More information about the libc-commits
mailing list