2010-12-11 03:47:54 +08:00
|
|
|
macro(pythonize_bool var)
|
|
|
|
if (${var})
|
|
|
|
set(${var} True)
|
|
|
|
else()
|
|
|
|
set(${var} False)
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
set(LIBCXX_LIT_VARIANT "libcxx" CACHE STRING
|
|
|
|
"Configuration variant to use for LIT.")
|
|
|
|
|
2018-02-23 23:19:48 +08:00
|
|
|
set(LIBCXX_TEST_LINKER_FLAGS "" CACHE STRING
|
|
|
|
"Additonal linker flags to pass when compiling the tests")
|
|
|
|
set(LIBCXX_TEST_COMPILER_FLAGS "" CACHE STRING
|
|
|
|
"Additonal linker flags to pass when compiling the tests")
|
|
|
|
|
2016-10-10 05:34:03 +08:00
|
|
|
# The tests shouldn't link to any ABI library when it has been linked into
|
|
|
|
# libc++ statically or via a linker script.
|
|
|
|
if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY OR LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
|
|
|
|
set(LIBCXX_CXX_ABI_LIBNAME "none")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# The tests shouldn't link to libunwind if we have a linker script which
|
|
|
|
# already does so.
|
|
|
|
if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
|
|
|
|
set(LIBCXXABI_USE_LLVM_UNWINDER OFF)
|
|
|
|
endif()
|
|
|
|
|
[libcxx] Allow tests to link with static libc++abi/libc++ even if the shared version is present
Summary:
This is essentially D71894, but for libc++.
This is needed for running libc++ tests over SSH.
Reviewers: EricWF, ldionne, phosek, mehdi_amini, mclow.lists, jroelofs, bcraig, #libc
Reviewed By: ldionne, phosek, #libc
Subscribers: mgorny, christof, dexonsmith, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D72687
2020-03-25 20:27:05 +08:00
|
|
|
option(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI
|
|
|
|
"Whether the libc++ tests should link with the shared libc++abi library"
|
|
|
|
${LIBCXXABI_ENABLE_SHARED})
|
|
|
|
|
|
|
|
option(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX
|
|
|
|
"Whether the libc++ tests should link with the shared libc++ library"
|
|
|
|
${LIBCXX_ENABLE_SHARED})
|
|
|
|
|
|
|
|
if(DEFINED LIBCXXABI_ENABLE_SHARED
|
|
|
|
AND LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI
|
|
|
|
AND NOT LIBCXXABI_ENABLE_SHARED)
|
|
|
|
message(FATAL_ERROR "LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI being ON requires LIBCXXABI_ENABLE_SHARED to be ON")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(DEFINED LIBCXXABI_ENABLE_STATIC
|
|
|
|
AND NOT LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI
|
|
|
|
AND NOT LIBCXXABI_ENABLE_STATIC)
|
|
|
|
message(FATAL_ERROR "LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI being OFF requires LIBCXXABI_ENABLE_STATIC to be ON")
|
|
|
|
endif()
|
|
|
|
|
2020-03-26 04:50:19 +08:00
|
|
|
if(LIBCXX_INCLUDE_TESTS AND LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX AND NOT LIBCXX_ENABLE_SHARED)
|
[libcxx] Allow tests to link with static libc++abi/libc++ even if the shared version is present
Summary:
This is essentially D71894, but for libc++.
This is needed for running libc++ tests over SSH.
Reviewers: EricWF, ldionne, phosek, mehdi_amini, mclow.lists, jroelofs, bcraig, #libc
Reviewed By: ldionne, phosek, #libc
Subscribers: mgorny, christof, dexonsmith, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D72687
2020-03-25 20:27:05 +08:00
|
|
|
message(FATAL_ERROR "LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX being ON requires LIBCXX_ENABLE_SHARED to be ON")
|
|
|
|
endif()
|
|
|
|
|
2020-03-26 04:50:19 +08:00
|
|
|
if(LIBCXX_INCLUDE_TESTS AND NOT LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX AND NOT LIBCXX_ENABLE_STATIC)
|
[libcxx] Allow tests to link with static libc++abi/libc++ even if the shared version is present
Summary:
This is essentially D71894, but for libc++.
This is needed for running libc++ tests over SSH.
Reviewers: EricWF, ldionne, phosek, mehdi_amini, mclow.lists, jroelofs, bcraig, #libc
Reviewed By: ldionne, phosek, #libc
Subscribers: mgorny, christof, dexonsmith, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D72687
2020-03-25 20:27:05 +08:00
|
|
|
message(FATAL_ERROR "LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX being OFF requires LIBCXX_ENABLE_STATIC to be ON")
|
|
|
|
endif()
|
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS)
|
2016-05-04 05:30:18 +08:00
|
|
|
pythonize_bool(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
|
2015-07-31 06:30:34 +08:00
|
|
|
pythonize_bool(LIBCXX_ENABLE_RTTI)
|
|
|
|
pythonize_bool(LIBCXX_ENABLE_SHARED)
|
[libcxx] Allow tests to link with static libc++abi/libc++ even if the shared version is present
Summary:
This is essentially D71894, but for libc++.
This is needed for running libc++ tests over SSH.
Reviewers: EricWF, ldionne, phosek, mehdi_amini, mclow.lists, jroelofs, bcraig, #libc
Reviewed By: ldionne, phosek, #libc
Subscribers: mgorny, christof, dexonsmith, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D72687
2020-03-25 20:27:05 +08:00
|
|
|
pythonize_bool(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX)
|
|
|
|
pythonize_bool(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI)
|
2019-03-21 08:04:31 +08:00
|
|
|
pythonize_bool(LIBCXX_ENABLE_FILESYSTEM)
|
2015-07-31 06:30:34 +08:00
|
|
|
pythonize_bool(LIBCXX_BUILD_32_BITS)
|
|
|
|
pythonize_bool(LIBCXX_GENERATE_COVERAGE)
|
2016-04-19 20:49:05 +08:00
|
|
|
pythonize_bool(LIBCXXABI_ENABLE_SHARED)
|
2015-07-31 06:30:34 +08:00
|
|
|
pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
|
2018-01-09 07:36:53 +08:00
|
|
|
pythonize_bool(LIBCXX_USE_COMPILER_RT)
|
2016-02-11 20:43:04 +08:00
|
|
|
pythonize_bool(LIBCXX_HAS_ATOMIC_LIB)
|
2016-07-18 14:01:50 +08:00
|
|
|
pythonize_bool(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB)
|
2017-01-07 04:05:40 +08:00
|
|
|
pythonize_bool(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY)
|
2017-01-14 15:54:39 +08:00
|
|
|
pythonize_bool(LIBCXX_DEBUG_BUILD)
|
2019-08-06 02:29:14 +08:00
|
|
|
pythonize_bool(LIBCXX_ENABLE_PARALLEL_ALGORITHMS)
|
2015-07-31 06:30:34 +08:00
|
|
|
|
2016-04-19 20:49:05 +08:00
|
|
|
# By default, for non-standalone builds, libcxx and libcxxabi share a library
|
|
|
|
# directory.
|
|
|
|
if (NOT LIBCXX_CXX_ABI_LIBRARY_PATH)
|
|
|
|
set(LIBCXX_CXX_ABI_LIBRARY_PATH "${LIBCXX_LIBRARY_DIR}" CACHE PATH
|
2020-01-31 19:35:43 +08:00
|
|
|
"The path to libc++abi library.")
|
2016-04-19 20:49:05 +08:00
|
|
|
endif()
|
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
set(LIBCXX_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(LIBCXX_EXECUTOR "${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/../utils/run.py" CACHE STRING
|
2015-07-31 06:30:34 +08:00
|
|
|
"Executor to use when running tests.")
|
|
|
|
|
|
|
|
set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
|
|
|
|
|
2018-11-15 04:38:46 +08: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-12 05:46:40 +08:00
|
|
|
endif()
|
|
|
|
|
2019-10-05 06:15:28 +08:00
|
|
|
# Turn this on by default when the pretty printers are python3
|
|
|
|
# compatible.
|
|
|
|
if(LIBCXX_TEST_GDB_PRETTY_PRINTERS)
|
|
|
|
find_program(LIBCXX_GDB gdb)
|
|
|
|
if (LIBCXX_GDB)
|
|
|
|
set(LIBCXX_GDB "${LIBCXX_GDB}")
|
|
|
|
message(STATUS "gdb found: ${LIBCXX_GDB}")
|
|
|
|
else()
|
|
|
|
message(STATUS "gdb not found. Disabling dependent tests.")
|
|
|
|
endif()
|
2019-09-06 04:44:08 +08:00
|
|
|
endif()
|
|
|
|
|
2017-03-02 05:53:30 +08:00
|
|
|
if (LIBCXX_INCLUDE_TESTS)
|
2017-12-01 11:16:50 +08:00
|
|
|
include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuit
|
|
|
|
|
|
|
|
configure_lit_site_cfg(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
|
|
|
|
|
2020-04-16 03:05:14 +08:00
|
|
|
add_custom_target(check-cxx-deps
|
|
|
|
DEPENDS cxx ${LIBCXX_TEST_DEPS}
|
|
|
|
COMMENT "Builds dependencies required to run the test suite.")
|
|
|
|
|
2017-03-02 05:53:30 +08:00
|
|
|
add_lit_testsuite(check-cxx
|
|
|
|
"Running libcxx tests"
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
2020-04-16 03:05:14 +08:00
|
|
|
DEPENDS check-cxx-deps)
|
2017-03-02 05:53:30 +08:00
|
|
|
endif()
|
2016-08-25 06:17:06 +08:00
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
if (LIBCXX_GENERATE_COVERAGE)
|
|
|
|
include(CodeCoverage)
|
|
|
|
set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/coverage")
|
2017-03-11 13:28:09 +08: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-31 06:30:34 +08: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-11 03:47:54 +08:00
|
|
|
endif()
|
2017-07-05 11:50:03 +08: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()
|