Skip to content

Commit 2121b96

Browse files
authored
[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.
1 parent fb6feb8 commit 2121b96

11 files changed

+109
-14
lines changed

libcxx/test/configs/llvm-libc++-shared-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 libc++
2-
# using either a DLL or a static library, with MinGW/Clang on Windows.
2+
# using a DLL with MinGW/Clang on Windows.
33

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

libcxx/test/configs/llvm-libc++-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 libc++
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

libcxxabi/src/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ endif()
306306

307307
# Add a meta-target for both libraries.
308308
add_custom_target(cxxabi DEPENDS ${LIBCXXABI_BUILD_TARGETS})
309-
add_dependencies(cxxabi-test-depends cxxabi cxx)
310309

311310
if (LIBCXXABI_INSTALL_LIBRARY)
312311
install(TARGETS ${LIBCXXABI_INSTALL_TARGETS}

libcxxabi/test/CMakeLists.txt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,57 @@ macro(pythonize_bool var)
88
endif()
99
endmacro()
1010

11+
set(LIBCXXABI_TESTING_INSTALL_PREFIX "${LIBCXXABI_BINARY_DIR}/test-suite-install")
12+
add_custom_target(libcxxabi-install-cxx-for-testing
13+
DEPENDS cxx-headers
14+
cxx
15+
cxx_experimental
16+
cxx-modules
17+
COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXXABI_TESTING_INSTALL_PREFIX}"
18+
COMMAND "${CMAKE_COMMAND}"
19+
-DCMAKE_INSTALL_COMPONENT=cxx-headers
20+
-DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
21+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
22+
COMMAND "${CMAKE_COMMAND}"
23+
-DCMAKE_INSTALL_COMPONENT=cxx-modules
24+
-DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
25+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
26+
COMMAND "${CMAKE_COMMAND}"
27+
-DCMAKE_INSTALL_COMPONENT=cxx
28+
-DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
29+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
30+
add_dependencies(cxxabi-test-depends libcxxabi-install-cxx-for-testing)
31+
32+
add_custom_target(libcxxabi-install-cxxabi-for-testing
33+
DEPENDS cxxabi-headers
34+
cxxabi
35+
COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXXABI_TESTING_INSTALL_PREFIX}"
36+
COMMAND "${CMAKE_COMMAND}"
37+
-DCMAKE_INSTALL_COMPONENT=cxxabi-headers
38+
-DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
39+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
40+
COMMAND "${CMAKE_COMMAND}"
41+
-DCMAKE_INSTALL_COMPONENT=cxxabi
42+
-DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
43+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
44+
add_dependencies(cxxabi-test-depends libcxxabi-install-cxxabi-for-testing)
45+
46+
if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
47+
add_custom_target(libcxxabi-install-unwind-for-testing
48+
DEPENDS unwind-headers
49+
unwind
50+
COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXXABI_TESTING_INSTALL_PREFIX}"
51+
COMMAND "${CMAKE_COMMAND}"
52+
-DCMAKE_INSTALL_COMPONENT=unwind-headers
53+
-DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
54+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
55+
COMMAND "${CMAKE_COMMAND}"
56+
-DCMAKE_INSTALL_COMPONENT=unwind
57+
-DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
58+
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
59+
add_dependencies(cxxabi-test-depends libcxxabi-install-unwind-for-testing)
60+
endif()
61+
1162
pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
1263

1364
set(AUTO_GEN_COMMENT "## Autogenerated by libcxxabi configuration.\n# Do not edit!")

libcxxabi/test/configs/cmake-bridge.cfg.in

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ config.test_exec_root = os.path.join('@CMAKE_BINARY_DIR@', 'test')
2727
config.host_triple = '@LLVM_HOST_TRIPLE@'
2828

2929
config.substitutions.append(('%{libcxx}', '@LIBCXXABI_LIBCXX_PATH@'))
30-
config.substitutions.append(('%{include}', '@LIBCXXABI_SOURCE_DIR@/include'))
31-
config.substitutions.append(('%{cxx-include}', '@LIBCXXABI_HEADER_DIR@/include/c++/v1'))
32-
config.substitutions.append(('%{cxx-target-include}', '@LIBCXXABI_HEADER_DIR@/include/%{triple}/c++/v1'))
33-
config.substitutions.append(('%{lib}', '@LIBCXXABI_LIBRARY_DIR@'))
30+
config.substitutions.append(('%{install-prefix}', '@LIBCXXABI_TESTING_INSTALL_PREFIX@'))
31+
config.substitutions.append(('%{include}', '@LIBCXXABI_TESTING_INSTALL_PREFIX@/include'))
32+
config.substitutions.append(('%{cxx-include}', '@LIBCXXABI_TESTING_INSTALL_PREFIX@/@LIBCXXABI_INSTALL_INCLUDE_DIR@'))
33+
config.substitutions.append(('%{cxx-target-include}', '@LIBCXXABI_TESTING_INSTALL_PREFIX@/include/%{triple}/c++/v1'))
34+
config.substitutions.append(('%{lib}', '@LIBCXXABI_TESTING_INSTALL_PREFIX@/@LIBCXXABI_INSTALL_LIBRARY_DIR@'))
3435

3536
if @LIBCXXABI_USE_LLVM_UNWINDER@:
3637
config.substitutions.append(('%{maybe-include-libunwind}', '-I "@LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL@"'))

libcxxabi/test/configs/llvm-libc++abi-mingw.cfg.in

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

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

@@ -11,7 +11,7 @@ config.substitutions.append(('%{link_flags}',
1111
'-nostdlib++ -L %{lib} -lc++'
1212
))
1313
config.substitutions.append(('%{exec}',
14-
'%{executor} --execdir %T --prepend_env PATH=%{lib} -- '
14+
'%{executor} --execdir %T --prepend_env PATH=%{install-prefix}/bin -- '
1515
))
1616

1717
import os, site

libunwind/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()

libunwind/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)

libunwind/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+
)

libunwind/test/configs/llvm-libunwind-mingw.cfg.in renamed to libunwind/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)