Skip to content

Commit b7cdaca

Browse files
ldionnecopybara-github
authored andcommitted
[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. NOKEYCHECK=True GitOrigin-RevId: 2121b961fd8f1cf5449a73a20643db53431e5bc0
1 parent 9846aba commit b7cdaca

File tree

5 files changed

+49
-5
lines changed

5 files changed

+49
-5
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ set(LIBUNWIND_LIBRARY_VERSION "1.0" CACHE STRING
6868
this also controls the linker's 'current_version' property.")
6969

7070
if(MINGW)
71-
set(LIBUNWIND_DEFAULT_TEST_CONFIG "llvm-libunwind-mingw.cfg.in")
71+
if (LIBUNWIND_ENABLE_SHARED)
72+
set(LIBUNWIND_DEFAULT_TEST_CONFIG "llvm-libunwind-shared-mingw.cfg.in")
73+
else()
74+
set(LIBUNWIND_DEFAULT_TEST_CONFIG "llvm-libunwind-static-mingw.cfg.in")
75+
endif()
7276
elseif (LIBUNWIND_ENABLE_SHARED)
7377
set(LIBUNWIND_DEFAULT_TEST_CONFIG "llvm-libunwind-shared.cfg.in")
7478
else()

test/CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@ macro(pythonize_bool var)
88
endif()
99
endmacro()
1010

11+
set(LIBUNWIND_TESTING_INSTALL_PREFIX "${LIBUNWIND_BINARY_DIR}/test-suite-install")
12+
add_custom_target(libunwind-install-unwind-for-testing
13+
DEPENDS unwind-headers
14+
unwind
15+
COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBUNWIND_TESTING_INSTALL_PREFIX}"
16+
COMMAND "${CMAKE_COMMAND}"
17+
-DCMAKE_INSTALL_COMPONENT=unwind-headers
18+
-DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
19+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
20+
COMMAND "${CMAKE_COMMAND}"
21+
-DCMAKE_INSTALL_COMPONENT=unwind
22+
-DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
23+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
24+
1125
pythonize_bool(LIBUNWIND_ENABLE_CET)
1226
pythonize_bool(LIBUNWIND_ENABLE_GCS)
1327
pythonize_bool(LIBUNWIND_ENABLE_THREADS)
@@ -48,4 +62,4 @@ configure_lit_site_cfg(
4862

4963
add_lit_testsuite(check-unwind "Running libunwind tests"
5064
${CMAKE_CURRENT_BINARY_DIR}
51-
DEPENDS unwind)
65+
DEPENDS libunwind-install-unwind-for-testing)

test/configs/cmake-bridge.cfg.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ if not @LIBUNWIND_ENABLE_THREADS@:
2929
config.available_features.add('libunwind-no-threads')
3030

3131
# Add substitutions for bootstrapping the test suite configuration
32-
config.substitutions.append(('%{include}', '@LIBUNWIND_SOURCE_DIR@/include'))
33-
config.substitutions.append(('%{lib}', '@LIBUNWIND_LIBRARY_DIR@'))
32+
config.substitutions.append(('%{install-prefix}', '@LIBUNWIND_TESTING_INSTALL_PREFIX@'))
33+
config.substitutions.append(('%{include}', '@LIBUNWIND_TESTING_INSTALL_PREFIX@/include'))
34+
config.substitutions.append(('%{lib}', '@LIBUNWIND_TESTING_INSTALL_PREFIX@/lib'))
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This testing configuration handles running the test suite against LLVM's libunwind
2+
# using a DLL with MinGW/Clang on Windows.
3+
4+
lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
5+
6+
config.substitutions.append(('%{flags}', ''))
7+
config.substitutions.append(('%{compile_flags}',
8+
'-nostdinc++ -I %{include} -funwind-tables'
9+
))
10+
config.substitutions.append(('%{link_flags}',
11+
'-L %{lib} -lunwind'
12+
))
13+
config.substitutions.append(('%{exec}',
14+
'%{executor} --execdir %T --prepend_env PATH=%{install-prefix}/bin -- '
15+
))
16+
17+
import os, site
18+
site.addsitedir(os.path.join('@LIBUNWIND_LIBCXX_PATH@', 'utils'))
19+
import libcxx.test.params, libcxx.test.config
20+
libcxx.test.config.configure(
21+
libcxx.test.params.DEFAULT_PARAMETERS,
22+
libcxx.test.features.DEFAULT_FEATURES,
23+
config,
24+
lit_config
25+
)

test/configs/llvm-libunwind-mingw.cfg.in renamed to test/configs/llvm-libunwind-static-mingw.cfg.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This testing configuration handles running the test suite against LLVM's libunwind
2-
# using either a DLL or a static library, with MinGW/Clang on Windows.
2+
# using a static library with MinGW/Clang on Windows.
33

44
lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
55

0 commit comments

Comments
 (0)