2021-07-07 21:45:26 +08:00
|
|
|
include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuite
|
2014-07-10 10:20:11 +08:00
|
|
|
macro(pythonize_bool var)
|
|
|
|
if (${var})
|
|
|
|
set(${var} True)
|
|
|
|
else()
|
|
|
|
set(${var} False)
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2016-04-19 20:47:38 +08:00
|
|
|
if (NOT DEFINED LIBCXX_ENABLE_SHARED)
|
|
|
|
set(LIBCXX_ENABLE_SHARED ON)
|
|
|
|
endif()
|
|
|
|
|
2020-01-30 18:05:14 +08:00
|
|
|
option(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI
|
|
|
|
"Whether the libc++abi tests should link with the shared libc++abi library"
|
|
|
|
${LIBCXXABI_ENABLE_SHARED})
|
|
|
|
|
|
|
|
option(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX
|
|
|
|
"Whether the libc++abi tests should link with the shared libc++ library"
|
|
|
|
${LIBCXX_ENABLE_SHARED})
|
|
|
|
|
|
|
|
if(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI AND NOT LIBCXXABI_ENABLE_SHARED)
|
|
|
|
message(FATAL_ERROR "LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI being ON requires LIBCXXABI_ENABLE_SHARED to be ON")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI AND NOT LIBCXXABI_ENABLE_STATIC)
|
|
|
|
message(FATAL_ERROR "LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI being OFF requires LIBCXXABI_ENABLE_STATIC to be ON")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX AND NOT LIBCXX_ENABLE_SHARED)
|
|
|
|
message(FATAL_ERROR "LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX being ON requires LIBCXX_ENABLE_SHARED to be ON")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(DEFINED LIBCXX_ENABLE_STATIC
|
2020-06-12 03:41:38 +08:00
|
|
|
AND NOT LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX
|
2020-01-30 18:05:14 +08:00
|
|
|
AND NOT LIBCXX_ENABLE_STATIC)
|
|
|
|
message(FATAL_ERROR "LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX being OFF requires LIBCXX_ENABLE_STATIC to be ON")
|
|
|
|
endif()
|
|
|
|
|
2016-04-19 20:47:38 +08:00
|
|
|
pythonize_bool(LIBCXX_ENABLE_SHARED)
|
2014-07-10 10:20:11 +08:00
|
|
|
pythonize_bool(LIBCXXABI_ENABLE_SHARED)
|
2014-11-25 06:42:03 +08:00
|
|
|
pythonize_bool(LIBCXXABI_ENABLE_THREADS)
|
2014-07-11 23:36:02 +08:00
|
|
|
pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
|
2019-02-05 12:44:03 +08:00
|
|
|
pythonize_bool(LIBCXXABI_USE_COMPILER_RT)
|
2017-01-09 19:57:21 +08:00
|
|
|
pythonize_bool(LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
|
2019-08-08 20:43:20 +08:00
|
|
|
pythonize_bool(LIBCXX_ENABLE_PARALLEL_ALGORITHMS)
|
[libcxxabi] Allow tests to link with static libc++abi/libc++ even if the shared version is present
Summary:
Right now the only way to force libc++abi tests to link with the static version of libc++abi is to set `LIBCXXABI_ENABLE_SHARED` to `OFF`. However, this doesn't work when libc++abi is built as standalone project because of [this](https://github.com/llvm/llvm-project/blob/54c522420347e58aa7bae1892cf5c5672b57c875/libcxxabi/CMakeLists.txt#L503-L519).
This change allows specifying the version of the library for tests to link with.
This is useful for remote testing, for example, with `SSHExecutor`, where we _have_ to link with libc++abi statically.
Two new CMake options are introduced here: `LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI` and `LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX`. They can be set to `OFF` to tell the test utility to link tests with the static libraries.
It shouldn't break anything, because the default values of these options are set such that the test utility will behave the same way.
Reviewers: EricWF, mclow.lists, phosek, mehdi_amini, ldionne, jroelofs, bcraig
Subscribers: mgorny, christof, ldionne, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D71894
2019-12-26 17:28:39 +08:00
|
|
|
pythonize_bool(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX)
|
|
|
|
pythonize_bool(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI)
|
2015-02-26 23:55:01 +08:00
|
|
|
set(LIBCXXABI_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
|
|
|
|
"TargetInfo to use when setting up test environment.")
|
2020-06-12 03:41:38 +08:00
|
|
|
set(LIBCXXABI_EXECUTOR "${Python3_EXECUTABLE} ${LIBCXXABI_LIBCXX_PATH}/utils/run.py" CACHE STRING
|
2015-02-26 23:55:01 +08:00
|
|
|
"Executor to use when running tests.")
|
2014-07-10 10:20:11 +08:00
|
|
|
|
2016-04-19 20:47:38 +08:00
|
|
|
if (LIBCXXABI_ENABLE_SHARED)
|
|
|
|
set(LIBCXXABI_TEST_DEPS cxxabi_shared)
|
|
|
|
else()
|
|
|
|
set(LIBCXXABI_TEST_DEPS cxxabi_static)
|
|
|
|
endif()
|
|
|
|
|
2017-01-09 19:57:21 +08:00
|
|
|
if (LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY)
|
2017-01-03 20:58:34 +08:00
|
|
|
list(APPEND LIBCXXABI_TEST_DEPS cxx_external_threads)
|
|
|
|
endif()
|
|
|
|
|
2022-05-14 00:15:15 +08:00
|
|
|
list(APPEND LIBCXXABI_TEST_DEPS cxx)
|
|
|
|
if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
|
|
|
|
list(APPEND LIBCXXABI_TEST_DEPS unwind)
|
2014-07-11 23:36:02 +08:00
|
|
|
endif()
|
|
|
|
|
2020-06-25 23:46:00 +08:00
|
|
|
set(AUTO_GEN_COMMENT "## Autogenerated by libcxxabi configuration.\n# Do not edit!")
|
2021-06-02 05:16:11 +08:00
|
|
|
set(SERIALIZED_LIT_PARAMS "# Lit parameters serialized here for llvm-lit to pick them up\n")
|
|
|
|
|
|
|
|
macro(serialize_lit_param param value)
|
|
|
|
string(APPEND SERIALIZED_LIT_PARAMS "config.${param} = ${value}\n")
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
if (NOT LIBCXXABI_ENABLE_EXCEPTIONS)
|
|
|
|
serialize_lit_param(enable_exceptions False)
|
|
|
|
endif()
|
|
|
|
|
2022-03-29 01:10:14 +08:00
|
|
|
if (LIBCXXABI_ENABLE_ASSERTIONS)
|
|
|
|
serialize_lit_param(enable_assertions True)
|
|
|
|
endif()
|
|
|
|
|
2021-06-02 05:16:11 +08:00
|
|
|
serialize_lit_param(enable_experimental False)
|
|
|
|
|
|
|
|
if (LLVM_USE_SANITIZER)
|
|
|
|
serialize_lit_param(use_sanitizer "\"${LLVM_USE_SANITIZER}\"")
|
|
|
|
endif()
|
|
|
|
|
2021-10-13 03:59:08 +08:00
|
|
|
if (CMAKE_CXX_COMPILER_TARGET)
|
|
|
|
serialize_lit_param(target_triple "\"${CMAKE_CXX_COMPILER_TARGET}\"")
|
|
|
|
else()
|
|
|
|
serialize_lit_param(target_triple "\"${LLVM_DEFAULT_TARGET_TRIPLE}\"")
|
2021-06-02 05:16:11 +08:00
|
|
|
endif()
|
|
|
|
|
[runtimes] Serialize all Lit params instead of passing them to add_lit_testsuite
add_lit_testsuite() takes Lit parameters passed to it and adds them
to the parameters used globally when running all test suites. That
means that a target like `check-all`, which ends up calling Lit on
the whole monorepo, will see the test parameters for all the individual
project's test suites.
So, for example, it would see `--param std=c++03` (from libc++abi), and
`--param std=c++03` (from libc++), and `--param whatever` (from another
project being tested at the same time). While always unclean, that works
when the parameters all agree. However, if the parameters share the same
name but have different values, only one of those two values will be used
and it will be incredibly confusing to understand why one of the test
suites is being run with the incorrect parameter value.
For that reason, this commit moves away from using add_lit_testsuite()'s
PARAM functionality, and serializes the parameter values for the runtimes
in the generated config.py file instead, which is local to the specific
test suite.
Differential Revision: https://reviews.llvm.org/D105991
2021-07-14 23:36:22 +08:00
|
|
|
foreach(param IN LISTS LIBCXXABI_TEST_PARAMS)
|
|
|
|
string(REGEX REPLACE "(.+)=(.+)" "\\1" name "${param}")
|
|
|
|
string(REGEX REPLACE "(.+)=(.+)" "\\2" value "${param}")
|
|
|
|
serialize_lit_param("${name}" "\"${value}\"")
|
|
|
|
endforeach()
|
|
|
|
|
2021-10-13 05:45:45 +08:00
|
|
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/cmake-bridge.cfg.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake-bridge.cfg"
|
|
|
|
@ONLY)
|
|
|
|
|
2018-01-18 06:07:09 +08:00
|
|
|
configure_lit_site_cfg(
|
2020-06-25 23:46:00 +08:00
|
|
|
"${LIBCXXABI_TEST_CONFIG}"
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
|
|
|
|
MAIN_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py")
|
2018-01-18 06:07:09 +08:00
|
|
|
|
2021-03-04 14:40:11 +08:00
|
|
|
add_lit_testsuite(check-cxxabi "Running libcxxabi tests"
|
2014-07-10 10:20:11 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
[runtimes] Serialize all Lit params instead of passing them to add_lit_testsuite
add_lit_testsuite() takes Lit parameters passed to it and adds them
to the parameters used globally when running all test suites. That
means that a target like `check-all`, which ends up calling Lit on
the whole monorepo, will see the test parameters for all the individual
project's test suites.
So, for example, it would see `--param std=c++03` (from libc++abi), and
`--param std=c++03` (from libc++), and `--param whatever` (from another
project being tested at the same time). While always unclean, that works
when the parameters all agree. However, if the parameters share the same
name but have different values, only one of those two values will be used
and it will be incredibly confusing to understand why one of the test
suites is being run with the incorrect parameter value.
For that reason, this commit moves away from using add_lit_testsuite()'s
PARAM functionality, and serializes the parameter values for the runtimes
in the generated config.py file instead, which is local to the specific
test suite.
Differential Revision: https://reviews.llvm.org/D105991
2021-07-14 23:36:22 +08:00
|
|
|
DEPENDS ${LIBCXXABI_TEST_DEPS})
|