File tree 2 files changed +10
-0
lines changed 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ set(LIBC_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
39
39
40
40
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" )
41
41
42
+ set (LIBC_KERNEL_HEADERS "/usr/include" CACHE STRING "Path to Linux kernel headers" )
43
+
42
44
# Defining a global namespace to enclose all libc functions.
43
45
set (default_namespace "__llvm_libc" )
44
46
if (LLVM_VERSION_MAJOR)
Original file line number Diff line number Diff line change @@ -51,9 +51,17 @@ function(_get_common_compile_options output_var flags)
51
51
if (LIBC_CC_SUPPORTS_NOSTDLIBINC)
52
52
list (APPEND compile_options "-nostdlibinc" )
53
53
elseif (COMPILER_RESOURCE_DIR)
54
+ # TODO: We should require COMPILER_RESOURCE_DIR to be set.
54
55
list (APPEND compile_options "-isystem${COMPILER_RESOURCE_DIR} /include" )
55
56
list (APPEND compile_options "-nostdinc" )
56
57
endif ()
58
+ # TODO: We should set this unconditionally on Linux.
59
+ if (LIBC_TARGET_OS_IS_LINUX AND
60
+ (LIBC_CC_SUPPORTS_NOSTDLIBINC OR COMPILER_RESOURCE_DIR))
61
+ # We use -idirafter to avoid preempting libc's own headers in case the
62
+ # directory (e.g. /usr/include) contains other headers.
63
+ list (APPEND compile_options "-idirafter${LIBC_KERNEL_HEADERS} " )
64
+ endif ()
57
65
endif ()
58
66
59
67
if (LIBC_COMPILER_HAS_FIXED_POINT)
You can’t perform that action at this time.
0 commit comments