mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-18 06:46:41 +00:00

We always strive to test libc++ as close as possible to the way we are actually shipping it. This was approximated reasonably well by setting up the minimal driver flags when running the test suite, however we were running the test suite against the library located in the build directory. This patch improves the situation by installing the library (the headers, the built library, modules, etc) into a fake location and then running the test suite against that fake "installation root". This should open the door to getting rid of the temporary copy of the headers we make during the build process, however this is left for a future improvement. Note that this adds quite a bit of verbosity whenever running the test suite because we install the headers beforehand every time. We should be able to override this to silence it, however CMake doesn't currently give us a way to do that, see https://gitlab.kitware.com/cmake/cmake/-/issues/26085.
106 lines
4.7 KiB
CMake
106 lines
4.7 KiB
CMake
include(HandleLitArguments)
|
|
add_subdirectory(tools)
|
|
|
|
if (LIBCXX_INCLUDE_BENCHMARKS)
|
|
add_subdirectory(benchmarks)
|
|
endif()
|
|
|
|
# Install the library at a fake location so we can run the test suite against it.
|
|
# This ensures that we run the test suite against a setup that matches what we ship
|
|
# in production as closely as possible (in terms of file paths, rpaths, etc).
|
|
set(LIBCXX_TESTING_INSTALL_PREFIX "${LIBCXX_BINARY_DIR}/test-suite-install")
|
|
if (LIBCXX_CXX_ABI STREQUAL "libcxxabi")
|
|
add_custom_target(install-cxxabi-test-suite-prefix
|
|
DEPENDS cxxabi-headers
|
|
cxxabi
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
-DCMAKE_INSTALL_COMPONENT=cxxabi-headers
|
|
-DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
-DCMAKE_INSTALL_COMPONENT=cxxabi
|
|
-DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
|
|
add_dependencies(cxx-test-depends install-cxxabi-test-suite-prefix)
|
|
endif()
|
|
|
|
if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
|
|
add_custom_target(install-unwind-test-suite-prefix
|
|
DEPENDS unwind-headers
|
|
unwind
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
-DCMAKE_INSTALL_COMPONENT=unwind-headers
|
|
-DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
-DCMAKE_INSTALL_COMPONENT=unwind
|
|
-DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
|
|
add_dependencies(cxx-test-depends install-unwind-test-suite-prefix)
|
|
endif()
|
|
|
|
add_custom_target(install-cxx-test-suite-prefix
|
|
DEPENDS cxx-headers
|
|
cxx
|
|
cxx_experimental
|
|
cxx-modules
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
-DCMAKE_INSTALL_COMPONENT=cxx-headers
|
|
-DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
-DCMAKE_INSTALL_COMPONENT=cxx-modules
|
|
-DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
-DCMAKE_INSTALL_COMPONENT=cxx
|
|
-DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
|
|
-P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
|
|
add_dependencies(cxx-test-depends install-cxx-test-suite-prefix)
|
|
|
|
set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
|
|
set(SERIALIZED_LIT_PARAMS "# Lit parameters serialized here for llvm-lit to pick them up\n")
|
|
|
|
serialize_lit_string_param(SERIALIZED_LIT_PARAMS compiler "${CMAKE_CXX_COMPILER}")
|
|
|
|
if (NOT LIBCXX_ENABLE_EXCEPTIONS)
|
|
serialize_lit_param(SERIALIZED_LIT_PARAMS enable_exceptions False)
|
|
endif()
|
|
|
|
if (NOT LIBCXX_ENABLE_RTTI)
|
|
serialize_lit_param(SERIALIZED_LIT_PARAMS enable_rtti False)
|
|
endif()
|
|
|
|
serialize_lit_string_param(SERIALIZED_LIT_PARAMS hardening_mode "${LIBCXX_HARDENING_MODE}")
|
|
|
|
if (CMAKE_CXX_COMPILER_TARGET)
|
|
serialize_lit_string_param(SERIALIZED_LIT_PARAMS target_triple "${CMAKE_CXX_COMPILER_TARGET}")
|
|
else()
|
|
serialize_lit_string_param(SERIALIZED_LIT_PARAMS target_triple "${LLVM_DEFAULT_TARGET_TRIPLE}")
|
|
endif()
|
|
|
|
if (LLVM_USE_SANITIZER)
|
|
serialize_lit_string_param(SERIALIZED_LIT_PARAMS use_sanitizer "${LLVM_USE_SANITIZER}")
|
|
endif()
|
|
|
|
serialize_lit_params_list(SERIALIZED_LIT_PARAMS LIBCXX_TEST_PARAMS)
|
|
|
|
include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuite
|
|
|
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/cmake-bridge.cfg.in"
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake-bridge.cfg"
|
|
@ONLY)
|
|
|
|
configure_lit_site_cfg(
|
|
"${LIBCXX_TEST_CONFIG}"
|
|
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
|
|
MAIN_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py")
|
|
|
|
add_lit_testsuite(check-cxx
|
|
"Running libcxx tests"
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
|
DEPENDS cxx-test-depends)
|