Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[compiler-rt] Use installed libc++(abi) for tests instead of build tree #115077

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions compiler-rt/cmake/Modules/AddCompilerRT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -680,15 +680,16 @@ macro(add_custom_libcxx name prefix)

ExternalProject_Add(${name}
DEPENDS ${name}-clobber ${LIBCXX_DEPS}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/${name}
PREFIX ${prefix}
SOURCE_DIR ${LLVM_MAIN_SRC_DIR}/../runtimes
BINARY_DIR ${prefix}
BINARY_DIR ${prefix}/build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this an expected change? If so, doesn't that mean the -isystem path in fuzzer's CMakeLists.txt should include the /build/ prefix?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the install directory is ${prefix}, so it uses the installed headers now instead of the build tree.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So adding the /build suffix is intended then? We're seeing issues where certain C++ headers aren't found and it looks like someone else has commented the same as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is intentional - and the dependency for RTFuzzer is still there so I am not sure why it is failing for you:

    target_compile_options(RTfuzzer.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
    add_dependencies(RTfuzzer.${arch} libcxx_fuzzer_${arch}-install)

Copy link
Contributor

@thevinster thevinster Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I saw that. In our case, the headers were defined under ${LIBCXX_${arch}_PREFIX}/build/include/c++/v1, hence my suspicion on /build whether that was intentional. But perhaps, it might a configuration issue on our end. For now, I've disabled building fuzzer since it's not needed for our internal workloads.

CMAKE_ARGS ${CMAKE_PASSTHROUGH_VARIABLES}
${compiler_args}
${verbose}
-DCMAKE_C_FLAGS=${LIBCXX_C_FLAGS}
-DCMAKE_CXX_FLAGS=${LIBCXX_CXX_FLAGS}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY
-DLLVM_ENABLE_RUNTIMES=libcxx|libcxxabi
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF
Expand All @@ -701,16 +702,17 @@ macro(add_custom_libcxx name prefix)
-DLIBCXX_INCLUDE_BENCHMARKS=OFF
-DLIBCXX_INCLUDE_TESTS=OFF
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON
-DLLVM_INCLUDE_TESTS=OFF
-DLLVM_INCLUDE_DOCS=OFF
${LIBCXX_CMAKE_ARGS}
INSTALL_COMMAND ""
STEP_TARGETS configure build
STEP_TARGETS configure build install
BUILD_ALWAYS 1
USES_TERMINAL_CONFIGURE 1
USES_TERMINAL_BUILD 1
USES_TERMINAL_INSTALL 1
LIST_SEPARATOR |
EXCLUDE_FROM_ALL TRUE
BUILD_BYPRODUCTS "${prefix}/lib/libc++.a" "${prefix}/lib/libc++abi.a"
INSTALL_BYPRODUCTS "${prefix}/lib/libc++.a" "${prefix}/lib/libc++abi.a"
)

if (CMAKE_GENERATOR MATCHES "Make")
Expand Down
6 changes: 3 additions & 3 deletions compiler-rt/lib/fuzzer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ if(OS_NAME MATCHES "Android|Linux|Fuchsia" AND
-DLIBCXX_ABI_NAMESPACE=__Fuzzer
-DLIBCXX_ENABLE_EXCEPTIONS=OFF)
target_compile_options(RTfuzzer.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
add_dependencies(RTfuzzer.${arch} libcxx_fuzzer_${arch}-build)
add_dependencies(RTfuzzer.${arch} libcxx_fuzzer_${arch}-install)
target_compile_options(RTfuzzer_main.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
add_dependencies(RTfuzzer_main.${arch} libcxx_fuzzer_${arch}-build)
add_dependencies(RTfuzzer_main.${arch} libcxx_fuzzer_${arch}-install)
target_compile_options(RTfuzzer_interceptors.${arch} PRIVATE -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
add_dependencies(RTfuzzer_interceptors.${arch} libcxx_fuzzer_${arch}-build)
add_dependencies(RTfuzzer_interceptors.${arch} libcxx_fuzzer_${arch}-install)
partially_link_libcxx(fuzzer_no_main ${LIBCXX_${arch}_PREFIX} ${arch})
partially_link_libcxx(fuzzer_interceptors ${LIBCXX_${arch}_PREFIX} ${arch})
partially_link_libcxx(fuzzer ${LIBCXX_${arch}_PREFIX} ${arch})
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/lib/fuzzer/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if(COMPILER_RT_DEFAULT_TARGET_ARCH IN_LIST FUZZER_SUPPORTED_ARCH)
COMPILER_RT_LIBCXX_PATH AND
COMPILER_RT_LIBCXXABI_PATH)
file(GLOB libfuzzer_headers ../*.h)
set(LIBFUZZER_TEST_RUNTIME_DEPS libcxx_fuzzer_${arch}-build ${libfuzzer_headers})
set(LIBFUZZER_TEST_RUNTIME_DEPS libcxx_fuzzer_${arch}-install ${libfuzzer_headers})
set(LIBFUZZER_TEST_RUNTIME_CFLAGS -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
set(LIBFUZZER_TEST_RUNTIME_LINK_FLAGS ${LIBCXX_${arch}_PREFIX}/lib/libc++.a)
endif()
Expand Down
8 changes: 4 additions & 4 deletions compiler-rt/lib/msan/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ macro(msan_compile obj_list source arch kind cflags)
sanitizer_test_compile(
${obj_list} ${source} ${arch}
KIND ${kind}
COMPILE_DEPS ${MSAN_UNITTEST_HEADERS} libcxx_msan_${arch}-build
COMPILE_DEPS ${MSAN_UNITTEST_HEADERS} libcxx_msan_${arch}-install
DEPS msan
CFLAGS -isystem ${MSAN_LIBCXX_DIR}/../include/c++/v1
${MSAN_UNITTEST_INSTRUMENTED_CFLAGS} ${cflags}
Expand Down Expand Up @@ -117,10 +117,10 @@ macro(add_msan_tests_for_arch arch kind cflags)
DEPS ${MSAN_INST_LOADABLE_OBJECTS})

set(MSAN_TEST_OBJECTS ${MSAN_INST_TEST_OBJECTS} ${MSAN_INST_GTEST})
set(MSAN_TEST_DEPS ${MSAN_TEST_OBJECTS} libcxx_msan_${arch}-build
set(MSAN_TEST_DEPS ${MSAN_TEST_OBJECTS} libcxx_msan_${arch}-install
${MSAN_LOADABLE_SO}
"${MSAN_LIBCXX_DIR}/libc++.a" "${MSAN_LIBCXX_DIR}/libc++abi.a")
list(APPEND MSAN_TEST_DEPS msan libcxx_msan_${arch}-build)
"${MSAN_LIBCXX_DIR}/libc++.a" "${MSAN_LIBCXX_DIR}/libc++abi.a")
list(APPEND MSAN_TEST_DEPS msan libcxx_msan_${arch}-install)
get_target_flags_for_arch(${arch} TARGET_LINK_FLAGS)
add_compiler_rt_test(MsanUnitTests "Msan-${arch}${kind}-Test" ${arch}
OBJECTS ${MSAN_TEST_OBJECTS} "${MSAN_LIBCXX_DIR}/libc++.a" "${MSAN_LIBCXX_DIR}/libc++abi.a"
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/lib/tsan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if(COMPILER_RT_LIBCXX_PATH AND
DEPS ${TSAN_RUNTIME_LIBRARIES}
CFLAGS ${TARGET_CFLAGS} -fsanitize=thread
USE_TOOLCHAIN)
list(APPEND libcxx_tsan_deps libcxx_tsan_${arch}-build)
list(APPEND libcxx_tsan_deps libcxx_tsan_${arch}-install)
endforeach()

add_custom_target(libcxx_tsan DEPENDS ${libcxx_tsan_deps})
Expand Down
Loading