Skip to content

Commit 9c26170

Browse files
committed
[libc] Fix Linux kernel headers being included on all OS's
Summary: The changes in llvm/llvm-project@43bd7e3 altered how we handled including headers, this included the system on the GPU target which poisoned the include path that was curated to not include any system headers. Change this to only apply is the target OS is Linux.
1 parent bf2f577 commit 9c26170

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

libc/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ set(LIBC_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
4747

4848
set(LIBC_ENABLE_USE_BY_CLANG OFF CACHE BOOL "Whether or not to place libc in a build directory findable by a just built clang")
4949

50-
set(LIBC_KERNEL_HEADERS "/usr/include" CACHE STRING "Path to Linux kernel headers")
51-
5250
# Defining a global namespace to enclose all libc functions.
5351
set(default_namespace "__llvm_libc")
5452
if(LLVM_VERSION_MAJOR)
@@ -146,6 +144,11 @@ option(LLVM_LIBC_ALL_HEADERS "Outputs all functions in header files, regardless
146144

147145
option(LIBC_CONFIG_PATH "The path to user provided folder that configures the build for the target system." OFF)
148146

147+
if(LIBC_TARGET_OS_IS_LINUX)
148+
set(kernel_headers "/usr/include")
149+
endif()
150+
set(LIBC_KERNEL_HEADERS "${kernel_headers}" CACHE STRING "Path to Linux kernel headers")
151+
149152
set(LIBC_ENABLE_UNITTESTS ON)
150153
set(LIBC_ENABLE_HERMETIC_TESTS ${LLVM_LIBC_FULL_BUILD})
151154

runtimes/cmake/Modules/HandleLibC.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ elseif (RUNTIMES_USE_LIBC STREQUAL "llvm-libc")
3030
check_cxx_compiler_flag(-nostdlibinc CXX_SUPPORTS_NOSTDLIBINC_FLAG)
3131
if(CXX_SUPPORTS_NOSTDLIBINC_FLAG)
3232
target_compile_options(runtimes-libc-headers INTERFACE "-nostdlibinc")
33-
target_compile_options(runtimes-libc-headers INTERFACE "-idirafter${LIBC_KERNEL_HEADERS}")
33+
if(LIBC_KERNEL_HEADERS)
34+
target_compile_options(runtimes-libc-headers INTERFACE "-idirafter${LIBC_KERNEL_HEADERS}")
35+
endif()
3436
endif()
3537

3638
add_library(runtimes-libc-static INTERFACE)

0 commit comments

Comments
 (0)