[libc-commits] [libc] [libc] Include Linux kernel headers in the full build (PR #97486)
via libc-commits
libc-commits at lists.llvm.org
Tue Jul 2 14:53:21 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Petr Hosek (petrhosek)
<details>
<summary>Changes</summary>
When doing a full build for Linux, as of #<!-- -->97461 we no longer include system headers, but we need to include Linux kernel headers.
---
Full diff: https://github.com/llvm/llvm-project/pull/97486.diff
2 Files Affected:
- (modified) libc/CMakeLists.txt (+2)
- (modified) libc/cmake/modules/LLVMLibCCompileOptionRules.cmake (+3)
``````````diff
diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt
index 4ffcd55ba9500..013b17b03f570 100644
--- a/libc/CMakeLists.txt
+++ b/libc/CMakeLists.txt
@@ -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)
diff --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
index 28379213029a3..d6a8764c3de16 100644
--- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
+++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
@@ -54,6 +54,9 @@ function(_get_common_compile_options output_var flags)
list(APPEND compile_options "-isystem${COMPILER_RESOURCE_DIR}/include")
list(APPEND compile_options "-nostdinc")
endif()
+ if(LIBC_TARGET_OS_IS_LINUX)
+ list(APPEND compile_options "-idirafter${LIBC_KERNEL_HEADERS}")
+ endif()
endif()
if(LIBC_COMPILER_HAS_FIXED_POINT)
``````````
</details>
https://github.com/llvm/llvm-project/pull/97486
More information about the libc-commits
mailing list