File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 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})
3939
4040set (LIBC_ENABLE_USE_BY_CLANG OFF CACHE BOOL "Whether or not to place libc in a build directory findable by a just built clang" )
4141
42+ set (LIBC_KERNEL_HEADERS "/usr/include" CACHE STRING "Path to Linux kernel headers" )
43+
4244# Defining a global namespace to enclose all libc functions.
4345set (default_namespace "__llvm_libc" )
4446if (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)
5151 if (LIBC_CC_SUPPORTS_NOSTDLIBINC)
5252 list (APPEND compile_options "-nostdlibinc" )
5353 elseif (COMPILER_RESOURCE_DIR)
54+ # TODO: We should require COMPILER_RESOURCE_DIR to be set.
5455 list (APPEND compile_options "-isystem${COMPILER_RESOURCE_DIR} /include" )
5556 list (APPEND compile_options "-nostdinc" )
5657 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 ()
5765 endif ()
5866
5967 if (LIBC_COMPILER_HAS_FIXED_POINT)
You can’t perform that action at this time.
0 commit comments