Skip to content

Commit

Permalink
[libc] Include Linux kernel headers in the full build (llvm#97486)
Browse files Browse the repository at this point in the history
When doing a full build for Linux, as of llvm#97461 we no longer include
system headers, but we need to include Linux kernel headers.
  • Loading branch information
petrhosek authored and lravenclaw committed Jul 3, 2024
1 parent 89d45f9 commit f493b42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ set(LIBC_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})

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")

set(LIBC_KERNEL_HEADERS "/usr/include" CACHE STRING "Path to Linux kernel headers")

# Defining a global namespace to enclose all libc functions.
set(default_namespace "__llvm_libc")
if(LLVM_VERSION_MAJOR)
Expand Down
8 changes: 8 additions & 0 deletions libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,17 @@ function(_get_common_compile_options output_var flags)
if(LIBC_CC_SUPPORTS_NOSTDLIBINC)
list(APPEND compile_options "-nostdlibinc")
elseif(COMPILER_RESOURCE_DIR)
# TODO: We should require COMPILER_RESOURCE_DIR to be set.
list(APPEND compile_options "-isystem${COMPILER_RESOURCE_DIR}/include")
list(APPEND compile_options "-nostdinc")
endif()
# TODO: We should set this unconditionally on Linux.
if(LIBC_TARGET_OS_IS_LINUX AND
(LIBC_CC_SUPPORTS_NOSTDLIBINC OR COMPILER_RESOURCE_DIR))
# We use -idirafter to avoid preempting libc's own headers in case the
# directory (e.g. /usr/include) contains other headers.
list(APPEND compile_options "-idirafter${LIBC_KERNEL_HEADERS}")
endif()
endif()

if(LIBC_COMPILER_HAS_FIXED_POINT)
Expand Down

0 comments on commit f493b42

Please sign in to comment.