2022-05-13 12:15:15 -04:00
|
|
|
# By default, libcxx and libcxxabi share a library directory.
|
2016-04-19 12:49:05 +00:00
|
|
|
if (NOT LIBCXX_CXX_ABI_LIBRARY_PATH)
|
|
|
|
set(LIBCXX_CXX_ABI_LIBRARY_PATH "${LIBCXX_LIBRARY_DIR}" CACHE PATH
|
2020-01-31 14:35:43 +03:00
|
|
|
"The path to libc++abi library.")
|
2016-04-19 12:49:05 +00:00
|
|
|
endif()
|
|
|
|
|
2021-02-24 12:18:48 +02:00
|
|
|
set(LIBCXX_EXECUTOR "\\\"${Python3_EXECUTABLE}\\\" ${CMAKE_CURRENT_LIST_DIR}/../utils/run.py" CACHE STRING
|
2015-07-30 22:30:34 +00:00
|
|
|
"Executor to use when running tests.")
|
|
|
|
|
|
|
|
set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
|
2021-06-01 17:16:11 -04: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 LIBCXX_ENABLE_EXCEPTIONS)
|
|
|
|
serialize_lit_param(enable_exceptions False)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NOT LIBCXX_ENABLE_RTTI)
|
|
|
|
serialize_lit_param(enable_rtti False)
|
|
|
|
endif()
|
|
|
|
|
2022-03-28 13:10:14 -04:00
|
|
|
if (LIBCXX_ENABLE_ASSERTIONS)
|
|
|
|
serialize_lit_param(enable_assertions True)
|
|
|
|
endif()
|
|
|
|
|
2021-10-12 15:59:08 -04:00
|
|
|
if (CMAKE_CXX_COMPILER_TARGET)
|
|
|
|
serialize_lit_param(target_triple "\"${CMAKE_CXX_COMPILER_TARGET}\"")
|
|
|
|
else()
|
2022-12-05 22:20:51 +00:00
|
|
|
serialize_lit_param(target_triple "\"${LLVM_DEFAULT_TARGET_TRIPLE}\"")
|
2021-06-01 17:16:11 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LLVM_USE_SANITIZER)
|
|
|
|
serialize_lit_param(use_sanitizer "\"${LLVM_USE_SANITIZER}\"")
|
|
|
|
endif()
|
2015-07-30 22:30:34 +00:00
|
|
|
|
[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 11:36:22 -04:00
|
|
|
foreach(param IN LISTS LIBCXX_TEST_PARAMS)
|
|
|
|
string(REGEX REPLACE "(.+)=(.+)" "\\1" name "${param}")
|
|
|
|
string(REGEX REPLACE "(.+)=(.+)" "\\2" value "${param}")
|
|
|
|
serialize_lit_param("${name}" "\"${value}\"")
|
|
|
|
endforeach()
|
|
|
|
|
2018-11-14 20:38:46 +00:00
|
|
|
if (NOT DEFINED LIBCXX_TEST_DEPS)
|
|
|
|
message(FATAL_ERROR "Expected LIBCXX_TEST_DEPS to be defined")
|
[libcxx] Introduce an externally-threaded libc++ variant.
This patch further decouples libc++ from pthread, allowing libc++ to be built
against other threading systems. There are two main use cases:
- Building libc++ against a thread library other than pthreads.
- Building libc++ with an "external" thread API, allowing a separate library to
provide the implementation of that API.
The two use cases are quite similar, the second one being sligtly more
de-coupled than the first. The cmake option LIBCXX_HAS_EXTERNAL_THREAD_API
enables both kinds of builds. One needs to place an <__external_threading>
header file containing an implementation of the "libc++ thread API" declared
in the <__threading_support> header.
For the second use case, the implementation of the libc++ thread API can
delegate to a custom "external" thread API where the implementation of this
external API is provided in a seperate library. This mechanism allows toolchain
vendors to distribute a build of libc++ with a custom thread-porting-layer API
(which is the "external" API above), platform vendors (recipients of the
toolchain/libc++) are then required to provide their implementation of this API
to be linked with (end-user) C++ programs.
Note that the second use case still requires establishing the basic types that
get passed between the external thread library and the libc++ library
(e.g. __libcpp_mutex_t). These cannot be opaque pointer types (libc++ sources
won't compile otherwise). It should also be noted that the second use case can
have a slight performance penalty; as all the thread constructs need to cross a
library boundary through an additional function call.
When the header <__external_threading> is omitted, libc++ is built with the
"libc++ thread API" (declared in <__threading_support>) as the "external" thread
API (basic types are pthread based). An implementation (pthread based) of this
API is provided in test/support/external_threads.cpp, which is built into a
separate DSO and linked in when running the libc++ test suite. A test run
therefore demonstrates the second use case (less the intermediate custom API).
Differential revision: https://reviews.llvm.org/D21968
Reviewers: bcraig, compnerd, EricWF, mclow.lists
llvm-svn: 281179
2016-09-11 21:46:40 +00:00
|
|
|
endif()
|
|
|
|
|
2017-03-01 21:53:30 +00:00
|
|
|
if (LIBCXX_INCLUDE_TESTS)
|
2021-07-07 09:45:26 -04:00
|
|
|
include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuite
|
2017-12-01 03:16:50 +00:00
|
|
|
|
2021-09-30 13:23:39 -04:00
|
|
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/cmake-bridge.cfg.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake-bridge.cfg"
|
|
|
|
@ONLY)
|
|
|
|
|
2017-12-01 03:16:50 +00:00
|
|
|
configure_lit_site_cfg(
|
2020-06-12 15:19:55 -04:00
|
|
|
"${LIBCXX_TEST_CONFIG}"
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
|
|
|
|
MAIN_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py")
|
2017-12-01 03:16:50 +00:00
|
|
|
|
2021-01-12 10:56:57 -05:00
|
|
|
add_custom_target(cxx-test-depends
|
2020-04-15 15:05:14 -04:00
|
|
|
DEPENDS cxx ${LIBCXX_TEST_DEPS}
|
|
|
|
COMMENT "Builds dependencies required to run the test suite.")
|
|
|
|
|
2021-03-24 16:45:55 -04:00
|
|
|
add_lit_testsuite(check-cxx
|
2017-03-01 21:53:30 +00:00
|
|
|
"Running libcxx tests"
|
|
|
|
${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 11:36:22 -04:00
|
|
|
DEPENDS cxx-test-depends)
|
2017-03-01 21:53:30 +00:00
|
|
|
endif()
|
2016-08-24 22:17:06 +00:00
|
|
|
|
2015-07-30 22:30:34 +00:00
|
|
|
if (LIBCXX_GENERATE_COVERAGE)
|
|
|
|
include(CodeCoverage)
|
|
|
|
set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/coverage")
|
2017-03-11 05:28:09 +00:00
|
|
|
set(capture_dirs
|
|
|
|
"${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_objects.dir/"
|
|
|
|
"${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/"
|
|
|
|
"${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_experimental.dir/"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}")
|
2015-07-30 22:30:34 +00:00
|
|
|
set(extract_dirs "${LIBCXX_SOURCE_DIR}/include;${LIBCXX_SOURCE_DIR}/src")
|
|
|
|
setup_lcov_test_target_coverage("cxx" "${output_dir}" "${capture_dirs}" "${extract_dirs}")
|
2010-12-10 19:47:54 +00:00
|
|
|
endif()
|
2017-07-05 03:50:03 +00:00
|
|
|
|
|
|
|
if (LIBCXX_CONFIGURE_IDE)
|
|
|
|
# Create dummy targets for each of the tests in the test suite, this allows
|
|
|
|
# IDE's such as CLion to correctly highlight the tests because it knows
|
|
|
|
# roughly what include paths/compile flags/macro definitions are needed.
|
|
|
|
include_directories(support)
|
|
|
|
file(GLOB_RECURSE LIBCXX_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/*.pass.cpp)
|
|
|
|
file(GLOB LIBCXX_TEST_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/support/*)
|
|
|
|
file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*)
|
|
|
|
add_executable(libcxx_test_objects EXCLUDE_FROM_ALL
|
|
|
|
${LIBCXX_TESTS} ${LIBCXX_TEST_HEADERS} ${LIBCXX_HEADERS})
|
|
|
|
add_dependencies(libcxx_test_objects cxx)
|
|
|
|
|
|
|
|
split_list(LIBCXX_COMPILE_FLAGS)
|
|
|
|
split_list(LIBCXX_LINK_FLAGS)
|
|
|
|
|
|
|
|
set_target_properties(libcxx_test_objects
|
|
|
|
PROPERTIES
|
|
|
|
COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
|
|
|
|
LINK_FLAGS "${LIBCXX_LINK_FLAGS}"
|
|
|
|
EXCLUDE_FROM_ALL ON
|
|
|
|
)
|
|
|
|
endif()
|