Skip to content

Commit e88e2a8

Browse files
committed
[libcxx] Fix include directory order
It's important that the arch directory be included first so that its header files which interpose on the default include dir be included instead of the default ones. The clang driver [1] does this when not building with -nostdinc, the libcxx build should do the same. We found this after https://reviews.llvm.org/D154282 when cross compiling from non Linux to Linux. If the host machine was not Linux, _LIBCPP_HAS_NO_TIME_ZONE_DATABASE would be defined in the default include dir __config_site, while it was undefined in the arch specific one causing build failures.
1 parent 86f21e9 commit e88e2a8

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,8 +1029,10 @@ add_custom_target(generate-cxx-headers ALL DEPENDS ${_all_includes})
10291029
add_library(cxx-headers INTERFACE)
10301030
target_link_libraries(cxx-headers INTERFACE libcxx-abi-headers)
10311031
add_dependencies(cxx-headers generate-cxx-headers)
1032-
target_include_directories(cxx-headers INTERFACE ${LIBCXX_GENERATED_INCLUDE_DIR}
1033-
${LIBCXX_GENERATED_INCLUDE_TARGET_DIR})
1032+
# It's important that the arch directory be included first so that its header files
1033+
# which interpose on the default include dir be included instead of the default ones.
1034+
target_include_directories(cxx-headers INTERFACE ${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}
1035+
${LIBCXX_GENERATED_INCLUDE_DIR})
10341036

10351037
if (LIBCXX_INSTALL_HEADERS)
10361038
foreach(file ${files})

libcxx/modules/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ if ("${LIBCXX_GENERATED_INCLUDE_DIR}" STREQUAL "${LIBCXX_GENERATED_INCLUDE_TARGE
128128
# This typically happens when the target is not installed.
129129
set(LIBCXX_CONFIGURED_INCLUDE_DIRS "${LIBCXX_GENERATED_INCLUDE_DIR}")
130130
else()
131+
# It's important that the arch directory be included first so that its header files
132+
# which interpose on the default include dir be included instead of the default ones.
131133
set(LIBCXX_CONFIGURED_INCLUDE_DIRS
132-
"${LIBCXX_GENERATED_INCLUDE_DIR};${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}"
134+
"${LIBCXX_GENERATED_INCLUDE_TARGET_DIR};${LIBCXX_GENERATED_INCLUDE_DIR}"
133135
)
134136
endif()
135137
configure_file(

0 commit comments

Comments
 (0)