diff --git a/libc/cmake/modules/LLVMLibCObjectRules.cmake b/libc/cmake/modules/LLVMLibCObjectRules.cmake --- a/libc/cmake/modules/LLVMLibCObjectRules.cmake +++ b/libc/cmake/modules/LLVMLibCObjectRules.cmake @@ -217,7 +217,8 @@ # X warnings generated. # Until this is fixed upstream, we use -fno-caret-diagnostics to surpress # these. - COMMAND $ "--extra-arg=-fno-caret-diagnostics" --quiet + COMMAND $ --system-headers + "--extra-arg=-fno-caret-diagnostics" --quiet # Path to directory containing compile_commands.json -p ${PROJECT_BINARY_DIR} ${ADD_ENTRYPOINT_OBJ_SRCS} diff --git a/libc/src/.clang-tidy b/libc/src/.clang-tidy --- a/libc/src/.clang-tidy +++ b/libc/src/.clang-tidy @@ -3,4 +3,4 @@ WarningsAsErrors: 'llvmlibc-*' CheckOptions: - key: llvmlibc-restrict-system-libc-headers.Includes - value: '-*, linux/*, asm/unistd.h' + value: '-*, linux/*, asm/*.h, asm-generic/*.h' diff --git a/libc/src/__support/common.h.def b/libc/src/__support/common.h.def --- a/libc/src/__support/common.h.def +++ b/libc/src/__support/common.h.def @@ -15,6 +15,14 @@ #define unlikely(x) __builtin_expect (x, 0) #define UNUSED __attribute__((unused)) +// This flag is used to indicate to the compiler whether it has access +// to a libc. It is used in compiler provided headers like stdint.h +// which contain an #include_next directive which extends the system header +// instead of replacing it. Therefore we want this to be set to false to prevent +// accidental inclusion of system headers and ensure use of stand alone headers. +#undef __STDC_HOSTED__ +#define __STDC_HOSTED__ 0 + Include the platform specific definitions at build time. For example, that of entrypoint macro. %%include_file(${platform_defs})