Skip to content

Commit fb8a7c7

Browse files
authored
[libunwind] Make sure libunwind test dependencies are installed before running tests (#171474)
This patch adds an installation step where we install libc++ in a fake installation tree before testing libunwind. This is necessary because some configurations (in particular "generic-merged") require libc++ to be installed, since the libunwind tests are actually linking libc++.so in which libc++abi.a and libunwind.a have been merged. Without this, we were actually failing to find `libc++.so` to link against and then linking against whatever system library we'd find in the provided search directories. While this happens to work in the current CI configuration, this breaks down when updating to newer build tools.
1 parent 5160a05 commit fb8a7c7

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

libunwind/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ if (RUNTIMES_EXECUTE_ONLY_CODE)
336336
add_compile_definitions(_LIBUNWIND_EXECUTE_ONLY_CODE)
337337
endif()
338338

339+
add_custom_target(unwind-test-depends
340+
COMMENT "Build dependencies required to run the libunwind test suite.")
341+
339342
#===============================================================================
340343
# Setup Source Code
341344
#===============================================================================

libunwind/test/CMakeLists.txt

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,22 @@ macro(pythonize_bool var)
88
endif()
99
endmacro()
1010

11+
# Install targets required to run libunwind tests into a temporary location.
12+
#
13+
# This ensures that we run the tests against the final installed products, which
14+
# is closer to what we actually ship than the contents of the build tree.
1115
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")
16+
set(libunwind_test_suite_install_targets unwind-headers unwind)
17+
if ("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES)
18+
list(APPEND libunwind_test_suite_install_targets cxx-headers cxx cxx_experimental cxx-modules cxxabi-headers cxxabi)
19+
endif()
20+
foreach(target IN LISTS libunwind_test_suite_install_targets)
21+
add_custom_target(libunwind-test-suite-install-${target} DEPENDS "${target}"
22+
COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_BINARY_DIR}"
23+
--prefix "${LIBUNWIND_TESTING_INSTALL_PREFIX}"
24+
--component "${target}")
25+
add_dependencies(unwind-test-depends libunwind-test-suite-install-${target})
26+
endforeach()
2427

2528
pythonize_bool(LIBUNWIND_ENABLE_CET)
2629
pythonize_bool(LIBUNWIND_ENABLE_GCS)
@@ -62,4 +65,4 @@ configure_lit_site_cfg(
6265

6366
add_lit_testsuite(check-unwind "Running libunwind tests"
6467
${CMAKE_CURRENT_BINARY_DIR}
65-
DEPENDS libunwind-install-unwind-for-testing)
68+
DEPENDS unwind-test-depends)

0 commit comments

Comments
 (0)