2017-07-06 23:20:12 +08:00
|
|
|
include(AddLLVM) # for add_lit_testsuite
|
|
|
|
macro(pythonize_bool var)
|
|
|
|
if (${var})
|
|
|
|
set(${var} True)
|
|
|
|
else()
|
|
|
|
set(${var} False)
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
if (NOT DEFINED LIBCXX_ENABLE_SHARED)
|
|
|
|
set(LIBCXX_ENABLE_SHARED ON)
|
|
|
|
endif()
|
|
|
|
|
[libunwind] Support stack unwind in CET environment
Control-flow Enforcement Technology (CET), published by Intel,
introduces shadow stack feature aiming to ensure a return from
a function is directed to where the function was called.
In a CET enabled system, each function call will push return
address into normal stack and shadow stack, when the function
returns, the address stored in shadow stack will be popped and
compared with the return address, program will fail if the 2
addresses don't match.
In exception handling, the control flow may skip some stack frames
and we must adjust shadow stack to avoid violating CET restriction.
In order to achieve this, we count the number of stack frames skipped
and adjust shadow stack by this number before jumping to landing pad.
Reviewed By: hjl.tools, compnerd, MaskRay
Differential Revision: https://reviews.llvm.org/D105968
Signed-off-by: gejin <ge.jin@intel.com>
2021-08-26 16:20:38 +08:00
|
|
|
pythonize_bool(LIBUNWIND_ENABLE_CET)
|
2017-07-06 23:20:12 +08:00
|
|
|
pythonize_bool(LIBCXX_ENABLE_SHARED)
|
|
|
|
pythonize_bool(LIBUNWIND_ENABLE_SHARED)
|
|
|
|
pythonize_bool(LIBUNWIND_ENABLE_THREADS)
|
2019-12-06 22:26:35 +08:00
|
|
|
pythonize_bool(LIBUNWIND_USES_ARM_EHABI)
|
2019-02-05 12:44:03 +08:00
|
|
|
pythonize_bool(LIBUNWIND_USE_COMPILER_RT)
|
2017-07-06 23:20:12 +08:00
|
|
|
pythonize_bool(LIBUNWIND_BUILD_EXTERNAL_THREAD_LIBRARY)
|
|
|
|
set(LIBUNWIND_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(LIBUNWIND_EXECUTOR "${Python3_EXECUTABLE} ${LIBUNWIND_LIBCXX_PATH}/utils/run.py" CACHE STRING
|
2017-07-06 23:20:12 +08:00
|
|
|
"Executor to use when running tests.")
|
|
|
|
|
|
|
|
set(AUTO_GEN_COMMENT "## Autogenerated by libunwind 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()
|
|
|
|
|
|
|
|
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 LIBUNWIND_TEST_PARAMS)
|
|
|
|
string(REGEX REPLACE "(.+)=(.+)" "\\1" name "${param}")
|
|
|
|
string(REGEX REPLACE "(.+)=(.+)" "\\2" value "${param}")
|
|
|
|
serialize_lit_param("${name}" "\"${value}\"")
|
|
|
|
endforeach()
|
|
|
|
|
2022-05-19 23:16:37 +08:00
|
|
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/cmake-bridge.cfg.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake-bridge.cfg"
|
|
|
|
@ONLY)
|
|
|
|
|
2020-06-26 00:02:43 +08:00
|
|
|
configure_lit_site_cfg(
|
|
|
|
"${LIBUNWIND_TEST_CONFIG}"
|
2017-07-06 23:20:12 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
|
2020-06-26 00:02:43 +08:00
|
|
|
MAIN_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py")
|
2017-07-06 23:20:12 +08:00
|
|
|
|
|
|
|
add_lit_testsuite(check-unwind "Running libunwind 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 23:36:22 +08:00
|
|
|
DEPENDS unwind ${LIBUNWIND_TEST_DEPS})
|