[libunwind] [libunwind] Make sure libunwind test dependencies are installed before running tests (PR #171474)
Louis Dionne via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 9 13:48:17 PST 2025
https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/171474
>From be09c5985dfff239132e08951c34c048987617c2 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 9 Dec 2025 11:04:36 -0500
Subject: [PATCH 1/6] [libunwind] Make sure libunwind test dependencies are
installed before running tests
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.
---
libunwind/CMakeLists.txt | 3 +++
libunwind/test/CMakeLists.txt | 23 ++++++++++++++++++++++-
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index 97edff0b87ea3..fbef71f3f7446 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -336,6 +336,9 @@ if (RUNTIMES_EXECUTE_ONLY_CODE)
add_compile_definitions(_LIBUNWIND_EXECUTE_ONLY_CODE)
endif()
+add_custom_target(unwind-test-depends
+ COMMENT "Build dependencies required to run the libunwind test suite.")
+
#===============================================================================
# Setup Source Code
#===============================================================================
diff --git a/libunwind/test/CMakeLists.txt b/libunwind/test/CMakeLists.txt
index c222c0bdbf5af..815bc86692860 100644
--- a/libunwind/test/CMakeLists.txt
+++ b/libunwind/test/CMakeLists.txt
@@ -9,6 +9,26 @@ macro(pythonize_bool var)
endmacro()
set(LIBUNWIND_TESTING_INSTALL_PREFIX "${LIBUNWIND_BINARY_DIR}/test-suite-install")
+add_custom_target(libunwind-install-cxx-for-testing
+ DEPENDS cxx-headers
+ cxx
+ cxx_experimental
+ cxx-modules
+ COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBUNWIND_TESTING_INSTALL_PREFIX}"
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=cxx-headers
+ -DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=cxx-modules
+ -DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=cxx
+ -DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+add_dependencies(unwind-test-depends libunwind-install-cxx-for-testing)
+
add_custom_target(libunwind-install-unwind-for-testing
DEPENDS unwind-headers
unwind
@@ -21,6 +41,7 @@ add_custom_target(libunwind-install-unwind-for-testing
-DCMAKE_INSTALL_COMPONENT=unwind
-DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+add_dependencies(unwind-test-depends libunwind-install-unwind-for-testing)
pythonize_bool(LIBUNWIND_ENABLE_CET)
pythonize_bool(LIBUNWIND_ENABLE_GCS)
@@ -62,4 +83,4 @@ configure_lit_site_cfg(
add_lit_testsuite(check-unwind "Running libunwind tests"
${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS libunwind-install-unwind-for-testing)
+ DEPENDS unwind-test-depends)
>From 95e23004a1c33432171082befef61549c5dc45a2 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 9 Dec 2025 15:28:06 -0500
Subject: [PATCH 2/6] Fix build when libc++ is not included in the build
---
libunwind/test/CMakeLists.txt | 40 ++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 19 deletions(-)
diff --git a/libunwind/test/CMakeLists.txt b/libunwind/test/CMakeLists.txt
index 815bc86692860..bfc47c45c014b 100644
--- a/libunwind/test/CMakeLists.txt
+++ b/libunwind/test/CMakeLists.txt
@@ -9,25 +9,27 @@ macro(pythonize_bool var)
endmacro()
set(LIBUNWIND_TESTING_INSTALL_PREFIX "${LIBUNWIND_BINARY_DIR}/test-suite-install")
-add_custom_target(libunwind-install-cxx-for-testing
- DEPENDS cxx-headers
- cxx
- cxx_experimental
- cxx-modules
- COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBUNWIND_TESTING_INSTALL_PREFIX}"
- COMMAND "${CMAKE_COMMAND}"
- -DCMAKE_INSTALL_COMPONENT=cxx-headers
- -DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
- -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
- COMMAND "${CMAKE_COMMAND}"
- -DCMAKE_INSTALL_COMPONENT=cxx-modules
- -DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
- -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
- COMMAND "${CMAKE_COMMAND}"
- -DCMAKE_INSTALL_COMPONENT=cxx
- -DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
- -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
-add_dependencies(unwind-test-depends libunwind-install-cxx-for-testing)
+if ("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES)
+ add_custom_target(libunwind-install-cxx-for-testing
+ DEPENDS cxx-headers
+ cxx
+ cxx_experimental
+ cxx-modules
+ COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBUNWIND_TESTING_INSTALL_PREFIX}"
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=cxx-headers
+ -DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=cxx-modules
+ -DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=cxx
+ -DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+ add_dependencies(unwind-test-depends libunwind-install-cxx-for-testing)
+endif()
add_custom_target(libunwind-install-unwind-for-testing
DEPENDS unwind-headers
>From ead7697f82e831cc34169d71858062b5b5ed7c3b Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 9 Dec 2025 15:32:08 -0500
Subject: [PATCH 3/6] Make sure we also install libc++abi to the
fake-test-install location
---
libunwind/test/CMakeLists.txt | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/libunwind/test/CMakeLists.txt b/libunwind/test/CMakeLists.txt
index bfc47c45c014b..1b7ff367ee516 100644
--- a/libunwind/test/CMakeLists.txt
+++ b/libunwind/test/CMakeLists.txt
@@ -29,6 +29,20 @@ if ("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES)
-DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
add_dependencies(unwind-test-depends libunwind-install-cxx-for-testing)
+
+ add_custom_target(libunwind-install-cxxabi-for-testing
+ DEPENDS cxxabi-headers
+ cxxabi
+ COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBUNWIND_TESTING_INSTALL_PREFIX}"
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=cxxabi-headers
+ -DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
+ COMMAND "${CMAKE_COMMAND}"
+ -DCMAKE_INSTALL_COMPONENT=cxxabi
+ -DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
+ -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
+ add_dependencies(unwind-test-depends libunwind-install-cxxabi-for-testing)
endif()
add_custom_target(libunwind-install-unwind-for-testing
>From 56e5a6378d0461e6470e048f0572e013fabfe936 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 9 Dec 2025 15:45:45 -0500
Subject: [PATCH 4/6] Modernize and refactor per review comments
---
libunwind/test/CMakeLists.txt | 60 ++++++++---------------------------
1 file changed, 13 insertions(+), 47 deletions(-)
diff --git a/libunwind/test/CMakeLists.txt b/libunwind/test/CMakeLists.txt
index 1b7ff367ee516..42838218dac49 100644
--- a/libunwind/test/CMakeLists.txt
+++ b/libunwind/test/CMakeLists.txt
@@ -8,56 +8,22 @@ macro(pythonize_bool var)
endif()
endmacro()
+# Install targets required to run libunwind tests into a temporary location.
+#
+# This ensures that we run the tests against the final installed products, which
+# is closer to what we actually ship than the contents of the build tree.
set(LIBUNWIND_TESTING_INSTALL_PREFIX "${LIBUNWIND_BINARY_DIR}/test-suite-install")
+set(libunwind_test_suite_install_targets unwind-headers unwind)
if ("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES)
- add_custom_target(libunwind-install-cxx-for-testing
- DEPENDS cxx-headers
- cxx
- cxx_experimental
- cxx-modules
- COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBUNWIND_TESTING_INSTALL_PREFIX}"
- COMMAND "${CMAKE_COMMAND}"
- -DCMAKE_INSTALL_COMPONENT=cxx-headers
- -DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
- -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
- COMMAND "${CMAKE_COMMAND}"
- -DCMAKE_INSTALL_COMPONENT=cxx-modules
- -DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
- -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
- COMMAND "${CMAKE_COMMAND}"
- -DCMAKE_INSTALL_COMPONENT=cxx
- -DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
- -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
- add_dependencies(unwind-test-depends libunwind-install-cxx-for-testing)
-
- add_custom_target(libunwind-install-cxxabi-for-testing
- DEPENDS cxxabi-headers
- cxxabi
- COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBUNWIND_TESTING_INSTALL_PREFIX}"
- COMMAND "${CMAKE_COMMAND}"
- -DCMAKE_INSTALL_COMPONENT=cxxabi-headers
- -DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
- -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
- COMMAND "${CMAKE_COMMAND}"
- -DCMAKE_INSTALL_COMPONENT=cxxabi
- -DCMAKE_INSTALL_PREFIX="${LIBUNWIND_TESTING_INSTALL_PREFIX}"
- -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
- add_dependencies(unwind-test-depends libunwind-install-cxxabi-for-testing)
+ list(APPEND libunwind_test_suite_install_targets cxx-headers cxx cxx_experimental cxx-modules cxxabi-headers cxxabi)
endif()
-
-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")
-add_dependencies(unwind-test-depends libunwind-install-unwind-for-testing)
+foreach(target IN LISTS libunwind_test_suite_install_targets)
+ add_custom_target(libunwind-test-suite-install-${target} DEPENDS "${target}"
+ COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_BINARY_DIR}"
+ --prefix "${LIBUNWIND_TESTING_INSTALL_PREFIX}"
+ --component "${target}")
+ add_dependencies(unwind-test-depends libunwind-test-suite-install-${target})
+endforeach()
pythonize_bool(LIBUNWIND_ENABLE_CET)
pythonize_bool(LIBUNWIND_ENABLE_GCS)
>From 5e65d3546293203d24365d535d8981b5c54a0e5b Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 9 Dec 2025 16:31:34 -0500
Subject: [PATCH 5/6] Run installation targets serially to avoid races
---
libunwind/test/CMakeLists.txt | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libunwind/test/CMakeLists.txt b/libunwind/test/CMakeLists.txt
index 42838218dac49..19cb9e5b9a982 100644
--- a/libunwind/test/CMakeLists.txt
+++ b/libunwind/test/CMakeLists.txt
@@ -17,11 +17,14 @@ set(libunwind_test_suite_install_targets unwind-headers unwind)
if ("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES)
list(APPEND libunwind_test_suite_install_targets cxx-headers cxx cxx_experimental cxx-modules cxxabi-headers cxxabi)
endif()
+# Run installation targets serially to avoid race conditions between install targets
+set_property(GLOBAL PROPERTY JOB_POOLS libunwind-test-install-pool=1 APPEND)
foreach(target IN LISTS libunwind_test_suite_install_targets)
add_custom_target(libunwind-test-suite-install-${target} DEPENDS "${target}"
COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_BINARY_DIR}"
--prefix "${LIBUNWIND_TESTING_INSTALL_PREFIX}"
- --component "${target}")
+ --component "${target}"
+ JOB_POOL libunwind-test-install-pool)
add_dependencies(unwind-test-depends libunwind-test-suite-install-${target})
endforeach()
>From 84bca3d57e1749af81a272af4c1c0b45513ce5f1 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 9 Dec 2025 16:47:46 -0500
Subject: [PATCH 6/6] Revert "Run installation targets serially to avoid races"
Turns out I don't think this is helping at all, so remove it to
avoid increasing complexity.
---
libunwind/test/CMakeLists.txt | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/libunwind/test/CMakeLists.txt b/libunwind/test/CMakeLists.txt
index 19cb9e5b9a982..42838218dac49 100644
--- a/libunwind/test/CMakeLists.txt
+++ b/libunwind/test/CMakeLists.txt
@@ -17,14 +17,11 @@ set(libunwind_test_suite_install_targets unwind-headers unwind)
if ("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES)
list(APPEND libunwind_test_suite_install_targets cxx-headers cxx cxx_experimental cxx-modules cxxabi-headers cxxabi)
endif()
-# Run installation targets serially to avoid race conditions between install targets
-set_property(GLOBAL PROPERTY JOB_POOLS libunwind-test-install-pool=1 APPEND)
foreach(target IN LISTS libunwind_test_suite_install_targets)
add_custom_target(libunwind-test-suite-install-${target} DEPENDS "${target}"
COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_BINARY_DIR}"
--prefix "${LIBUNWIND_TESTING_INSTALL_PREFIX}"
- --component "${target}"
- JOB_POOL libunwind-test-install-pool)
+ --component "${target}")
add_dependencies(unwind-test-depends libunwind-test-suite-install-${target})
endforeach()
More information about the cfe-commits
mailing list