[libc++abi][libunwind] Run c++abi and unwind tests against a fake install root (#110171)

This is what we started doing in libc++ and it straightens up a lot of
things that only happened to work before, notably the presence of
relative rpaths in dylibs when running from the build tree.

This unlocks the ability to link against a just-built dylib but run
against another version of the dylib (for example the system-provided
one), which is necessary for proper backdeployment testing.

This patch adds a lot of code duplication between the libc++ and
libc++abi testing setups. However, there is already a large amount of
duplication and the only real way to get rid of it is to merge libc++abi
into libc++. In a way, this patch is a step in that direction because it
closes the gap between the two libraries' testing setup.
This commit is contained in:
Louis Dionne
2024-09-30 11:57:35 -04:00
committed by GitHub
parent fb6feb86a7
commit 2121b961fd
11 changed files with 109 additions and 14 deletions

View File

@@ -68,7 +68,11 @@ set(LIBUNWIND_LIBRARY_VERSION "1.0" CACHE STRING
this also controls the linker's 'current_version' property.")
if(MINGW)
set(LIBUNWIND_DEFAULT_TEST_CONFIG "llvm-libunwind-mingw.cfg.in")
if (LIBUNWIND_ENABLE_SHARED)
set(LIBUNWIND_DEFAULT_TEST_CONFIG "llvm-libunwind-shared-mingw.cfg.in")
else()
set(LIBUNWIND_DEFAULT_TEST_CONFIG "llvm-libunwind-static-mingw.cfg.in")
endif()
elseif (LIBUNWIND_ENABLE_SHARED)
set(LIBUNWIND_DEFAULT_TEST_CONFIG "llvm-libunwind-shared.cfg.in")
else()

View File

@@ -8,6 +8,20 @@ macro(pythonize_bool var)
endif()
endmacro()
set(LIBUNWIND_TESTING_INSTALL_PREFIX "${LIBUNWIND_BINARY_DIR}/test-suite-install")
add_custom_target(libunwind-install-unwind-for-testing
DEPENDS unwind-headers
unwind
COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBUNWIND_TESTING_INSTALL_PREFIX}"
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=unwind-headers
-DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=unwind
-DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
pythonize_bool(LIBUNWIND_ENABLE_CET)
pythonize_bool(LIBUNWIND_ENABLE_GCS)
pythonize_bool(LIBUNWIND_ENABLE_THREADS)
@@ -48,4 +62,4 @@ configure_lit_site_cfg(
add_lit_testsuite(check-unwind "Running libunwind tests"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS unwind)
DEPENDS libunwind-install-unwind-for-testing)

View File

@@ -29,5 +29,6 @@ if not @LIBUNWIND_ENABLE_THREADS@:
config.available_features.add('libunwind-no-threads')
# Add substitutions for bootstrapping the test suite configuration
config.substitutions.append(('%{include}', '@LIBUNWIND_SOURCE_DIR@/include'))
config.substitutions.append(('%{lib}', '@LIBUNWIND_LIBRARY_DIR@'))
config.substitutions.append(('%{install-prefix}', '@LIBUNWIND_TESTING_INSTALL_PREFIX@'))
config.substitutions.append(('%{include}', '@LIBUNWIND_TESTING_INSTALL_PREFIX@/include'))
config.substitutions.append(('%{lib}', '@LIBUNWIND_TESTING_INSTALL_PREFIX@/lib'))

View File

@@ -0,0 +1,25 @@
# This testing configuration handles running the test suite against LLVM's libunwind
# using a DLL with MinGW/Clang on Windows.
lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
config.substitutions.append(('%{flags}', ''))
config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I %{include} -funwind-tables'
))
config.substitutions.append(('%{link_flags}',
'-L %{lib} -lunwind'
))
config.substitutions.append(('%{exec}',
'%{executor} --execdir %T --prepend_env PATH=%{install-prefix}/bin -- '
))
import os, site
site.addsitedir(os.path.join('@LIBUNWIND_LIBCXX_PATH@', 'utils'))
import libcxx.test.params, libcxx.test.config
libcxx.test.config.configure(
libcxx.test.params.DEFAULT_PARAMETERS,
libcxx.test.features.DEFAULT_FEATURES,
config,
lit_config
)

View File

@@ -1,5 +1,5 @@
# This testing configuration handles running the test suite against LLVM's libunwind
# using either a DLL or a static library, with MinGW/Clang on Windows.
# using a static library with MinGW/Clang on Windows.
lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')