[Runtimes][libc] Include kernel headers when using RUNTIMES_USE_LIBC

When setting RUNTIMES_USE_LIBC=libc we pass -nostdlibinc if the compiler
supports it. This causes compilation failures when trying to build
libc++ as libc will try and reference kernel headers in its own headers
that it now cannot find. Explicitly reference the kernel headers so the
compiler can find them.

Reviewers: vonosmas, petrhosek, #reviewers-libcxx, michaelrj-google

Reviewed By: michaelrj-google

Pull Request: https://github.com/llvm/llvm-project/pull/165114
This commit is contained in:
Aiden Grossman 2025-11-01 12:50:41 -07:00 committed by GitHub
parent e7a23c4020
commit 43bd7e3bb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -30,6 +30,7 @@ elseif (RUNTIMES_USE_LIBC STREQUAL "llvm-libc")
check_cxx_compiler_flag(-nostdlibinc CXX_SUPPORTS_NOSTDLIBINC_FLAG)
if(CXX_SUPPORTS_NOSTDLIBINC_FLAG)
target_compile_options(runtimes-libc-headers INTERFACE "-nostdlibinc")
target_compile_options(runtimes-libc-headers INTERFACE "-idirafter${LIBC_KERNEL_HEADERS}")
endif()
add_library(runtimes-libc-static INTERFACE)