Skip to content

Commit e7bad34

Browse files
authored
[compiler-rt] Use installed libc++(abi) for tests instead of build tree
Using the build tree is somewhat fragile since the layout is not guaranteed to be stable and means the tests are tightly coupled to the libc++/libc++abi build tree layout. Instead update the ExternalProject to install the library and headers and do not add the build tree to the include/linker flags. Pull Request: #115077
1 parent a1be09a commit e7bad34

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

compiler-rt/cmake/Modules/AddCompilerRT.cmake

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -680,15 +680,16 @@ macro(add_custom_libcxx name prefix)
680680

681681
ExternalProject_Add(${name}
682682
DEPENDS ${name}-clobber ${LIBCXX_DEPS}
683-
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/${name}
683+
PREFIX ${prefix}
684684
SOURCE_DIR ${LLVM_MAIN_SRC_DIR}/../runtimes
685-
BINARY_DIR ${prefix}
685+
BINARY_DIR ${prefix}/build
686686
CMAKE_ARGS ${CMAKE_PASSTHROUGH_VARIABLES}
687687
${compiler_args}
688688
${verbose}
689689
-DCMAKE_C_FLAGS=${LIBCXX_C_FLAGS}
690690
-DCMAKE_CXX_FLAGS=${LIBCXX_CXX_FLAGS}
691691
-DCMAKE_BUILD_TYPE=Release
692+
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
692693
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
693694
-DLLVM_ENABLE_RUNTIMES=libcxx|libcxxabi
694695
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF
@@ -701,16 +702,17 @@ macro(add_custom_libcxx name prefix)
701702
-DLIBCXX_INCLUDE_BENCHMARKS=OFF
702703
-DLIBCXX_INCLUDE_TESTS=OFF
703704
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON
705+
-DLLVM_INCLUDE_TESTS=OFF
706+
-DLLVM_INCLUDE_DOCS=OFF
704707
${LIBCXX_CMAKE_ARGS}
705-
INSTALL_COMMAND ""
706-
STEP_TARGETS configure build
708+
STEP_TARGETS configure build install
707709
BUILD_ALWAYS 1
708710
USES_TERMINAL_CONFIGURE 1
709711
USES_TERMINAL_BUILD 1
710712
USES_TERMINAL_INSTALL 1
711713
LIST_SEPARATOR |
712714
EXCLUDE_FROM_ALL TRUE
713-
BUILD_BYPRODUCTS "${prefix}/lib/libc++.a" "${prefix}/lib/libc++abi.a"
715+
INSTALL_BYPRODUCTS "${prefix}/lib/libc++.a" "${prefix}/lib/libc++abi.a"
714716
)
715717

716718
if (CMAKE_GENERATOR MATCHES "Make")

compiler-rt/lib/fuzzer/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ if(OS_NAME MATCHES "Android|Linux|Fuchsia" AND
166166
-DLIBCXX_ABI_NAMESPACE=__Fuzzer
167167
-DLIBCXX_ENABLE_EXCEPTIONS=OFF)
168168
target_compile_options(RTfuzzer.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
169-
add_dependencies(RTfuzzer.${arch} libcxx_fuzzer_${arch}-build)
169+
add_dependencies(RTfuzzer.${arch} libcxx_fuzzer_${arch}-install)
170170
target_compile_options(RTfuzzer_main.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
171-
add_dependencies(RTfuzzer_main.${arch} libcxx_fuzzer_${arch}-build)
171+
add_dependencies(RTfuzzer_main.${arch} libcxx_fuzzer_${arch}-install)
172172
target_compile_options(RTfuzzer_interceptors.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
173-
add_dependencies(RTfuzzer_interceptors.${arch} libcxx_fuzzer_${arch}-build)
173+
add_dependencies(RTfuzzer_interceptors.${arch} libcxx_fuzzer_${arch}-install)
174174
partially_link_libcxx(fuzzer_no_main ${LIBCXX_${arch}_PREFIX} ${arch})
175175
partially_link_libcxx(fuzzer_interceptors ${LIBCXX_${arch}_PREFIX} ${arch})
176176
partially_link_libcxx(fuzzer ${LIBCXX_${arch}_PREFIX} ${arch})

compiler-rt/lib/fuzzer/tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ if(COMPILER_RT_DEFAULT_TARGET_ARCH IN_LIST FUZZER_SUPPORTED_ARCH)
6464
COMPILER_RT_LIBCXX_PATH AND
6565
COMPILER_RT_LIBCXXABI_PATH)
6666
file(GLOB libfuzzer_headers ../*.h)
67-
set(LIBFUZZER_TEST_RUNTIME_DEPS libcxx_fuzzer_${arch}-build ${libfuzzer_headers})
67+
set(LIBFUZZER_TEST_RUNTIME_DEPS libcxx_fuzzer_${arch}-install ${libfuzzer_headers})
6868
set(LIBFUZZER_TEST_RUNTIME_CFLAGS -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
6969
set(LIBFUZZER_TEST_RUNTIME_LINK_FLAGS ${LIBCXX_${arch}_PREFIX}/lib/libc++.a)
7070
endif()

compiler-rt/lib/msan/tests/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ macro(msan_compile obj_list source arch kind cflags)
6969
sanitizer_test_compile(
7070
${obj_list} ${source} ${arch}
7171
KIND ${kind}
72-
COMPILE_DEPS ${MSAN_UNITTEST_HEADERS} libcxx_msan_${arch}-build
72+
COMPILE_DEPS ${MSAN_UNITTEST_HEADERS} libcxx_msan_${arch}-install
7373
DEPS msan
7474
CFLAGS -isystem ${MSAN_LIBCXX_DIR}/../include/c++/v1
7575
${MSAN_UNITTEST_INSTRUMENTED_CFLAGS} ${cflags}
@@ -117,10 +117,10 @@ macro(add_msan_tests_for_arch arch kind cflags)
117117
DEPS ${MSAN_INST_LOADABLE_OBJECTS})
118118

119119
set(MSAN_TEST_OBJECTS ${MSAN_INST_TEST_OBJECTS} ${MSAN_INST_GTEST})
120-
set(MSAN_TEST_DEPS ${MSAN_TEST_OBJECTS} libcxx_msan_${arch}-build
120+
set(MSAN_TEST_DEPS ${MSAN_TEST_OBJECTS} libcxx_msan_${arch}-install
121121
${MSAN_LOADABLE_SO}
122-
"${MSAN_LIBCXX_DIR}/libc++.a" "${MSAN_LIBCXX_DIR}/libc++abi.a")
123-
list(APPEND MSAN_TEST_DEPS msan libcxx_msan_${arch}-build)
122+
"${MSAN_LIBCXX_DIR}/libc++.a" "${MSAN_LIBCXX_DIR}/libc++abi.a")
123+
list(APPEND MSAN_TEST_DEPS msan libcxx_msan_${arch}-install)
124124
get_target_flags_for_arch(${arch} TARGET_LINK_FLAGS)
125125
add_compiler_rt_test(MsanUnitTests "Msan-${arch}${kind}-Test" ${arch}
126126
OBJECTS ${MSAN_TEST_OBJECTS} "${MSAN_LIBCXX_DIR}/libc++.a" "${MSAN_LIBCXX_DIR}/libc++abi.a"

compiler-rt/lib/tsan/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if(COMPILER_RT_LIBCXX_PATH AND
3131
DEPS ${TSAN_RUNTIME_LIBRARIES}
3232
CFLAGS ${TARGET_CFLAGS} -fsanitize=thread
3333
USE_TOOLCHAIN)
34-
list(APPEND libcxx_tsan_deps libcxx_tsan_${arch}-build)
34+
list(APPEND libcxx_tsan_deps libcxx_tsan_${arch}-install)
3535
endforeach()
3636

3737
add_custom_target(libcxx_tsan DEPENDS ${libcxx_tsan_deps})

0 commit comments

Comments
 (0)