[libcxx-commits] [libcxx] [libcxxabi] [libc++] Simplify how we install test-suite dependencies (PR #171504)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Wed Dec 10 09:46:57 PST 2025


https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/171504

>From e265029b4d56fc6b6ea5579c476ff009ec05f59e Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 9 Dec 2025 15:52:55 -0500
Subject: [PATCH 1/5] [libc++] Simplify how we install test-suite dependencies

Based on comments in #171474, it was brought to my attention that
we can modernize and simplify how we perform the test suite installation
in libc++ and libc++abi.
---
 libcxx/test/CMakeLists.txt    | 57 ++++++---------------------------
 libcxxabi/test/CMakeLists.txt | 59 +++++++----------------------------
 2 files changed, 22 insertions(+), 94 deletions(-)

diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
index f4e577aed57de..57474f92a4bfd 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -5,57 +5,20 @@ add_subdirectory(tools)
 # This ensures that we run the test suite against a setup that matches what we ship
 # in production as closely as possible (in terms of file paths, rpaths, etc).
 set(LIBCXX_TESTING_INSTALL_PREFIX "${LIBCXX_BINARY_DIR}/test-suite-install")
+set(libcxx_test_suite_install_targets cxx-headers cxx cxx_experimental cxx-modules)
 if (LIBCXX_CXX_ABI STREQUAL "libcxxabi")
-  add_custom_target(install-cxxabi-test-suite-prefix
-                        DEPENDS cxxabi-headers
-                                cxxabi
-                        COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXX_TESTING_INSTALL_PREFIX}"
-                        COMMAND "${CMAKE_COMMAND}"
-                                -DCMAKE_INSTALL_COMPONENT=cxxabi-headers
-                                -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
-                                -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
-                        COMMAND "${CMAKE_COMMAND}"
-                                -DCMAKE_INSTALL_COMPONENT=cxxabi
-                                -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
-                                -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
-  add_dependencies(cxx-test-depends install-cxxabi-test-suite-prefix)
+  list(APPEND libcxx_test_suite_install_targets cxxabi-headers cxxabi)
 endif()
-
 if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
-  add_custom_target(install-unwind-test-suite-prefix
-  DEPENDS unwind-headers
-          unwind
-  COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXX_TESTING_INSTALL_PREFIX}"
-  COMMAND "${CMAKE_COMMAND}"
-          -DCMAKE_INSTALL_COMPONENT=unwind-headers
-          -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
-          -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
-  COMMAND "${CMAKE_COMMAND}"
-          -DCMAKE_INSTALL_COMPONENT=unwind
-          -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
-          -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
-  add_dependencies(cxx-test-depends install-unwind-test-suite-prefix)
+  list(APPEND libcxx_test_suite_install_targets unwind-headers unwind)
 endif()
-
-add_custom_target(install-cxx-test-suite-prefix
-                      DEPENDS cxx-headers
-                              cxx
-                              cxx_experimental
-                              cxx-modules
-                      COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXX_TESTING_INSTALL_PREFIX}"
-                      COMMAND "${CMAKE_COMMAND}"
-                              -DCMAKE_INSTALL_COMPONENT=cxx-headers
-                              -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
-                              -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
-                      COMMAND "${CMAKE_COMMAND}"
-                              -DCMAKE_INSTALL_COMPONENT=cxx-modules
-                              -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
-                              -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
-                      COMMAND "${CMAKE_COMMAND}"
-                              -DCMAKE_INSTALL_COMPONENT=cxx
-                              -DCMAKE_INSTALL_PREFIX="${LIBCXX_TESTING_INSTALL_PREFIX}"
-                              -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake")
-add_dependencies(cxx-test-depends install-cxx-test-suite-prefix)
+foreach(target IN LISTS libcxx_test_suite_install_targets)
+  add_custom_target(libcxx-test-suite-install-${target} DEPENDS "${target}"
+                    COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_BINARY_DIR}"
+                                               --prefix "${LIBCXX_TESTING_INSTALL_PREFIX}"
+                                               --component "${target}")
+  add_dependencies(cxx-test-depends libcxx-test-suite-install-${target})
+endforeach()
 
 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
 set(SERIALIZED_LIT_PARAMS "# Lit parameters serialized here for llvm-lit to pick them up\n")
diff --git a/libcxxabi/test/CMakeLists.txt b/libcxxabi/test/CMakeLists.txt
index 9eabfb08240b6..021bd7cc959e2 100644
--- a/libcxxabi/test/CMakeLists.txt
+++ b/libcxxabi/test/CMakeLists.txt
@@ -8,56 +8,21 @@ macro(pythonize_bool var)
   endif()
 endmacro()
 
+# Install the library and its dependencies at a fake location so we can run the test
+# suite against it. This ensures that we run the test suite against a setup that matches
+# what we ship in production as closely as possible (in terms of file paths, rpaths, etc).
 set(LIBCXXABI_TESTING_INSTALL_PREFIX "${LIBCXXABI_BINARY_DIR}/test-suite-install")
-add_custom_target(libcxxabi-install-cxx-for-testing
-                      DEPENDS cxx-headers
-                              cxx
-                              cxx_experimental
-                              cxx-modules
-                      COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXXABI_TESTING_INSTALL_PREFIX}"
-                      COMMAND "${CMAKE_COMMAND}"
-                              -DCMAKE_INSTALL_COMPONENT=cxx-headers
-                              -DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
-                              -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
-                      COMMAND "${CMAKE_COMMAND}"
-                              -DCMAKE_INSTALL_COMPONENT=cxx-modules
-                              -DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
-                              -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
-                      COMMAND "${CMAKE_COMMAND}"
-                              -DCMAKE_INSTALL_COMPONENT=cxx
-                              -DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
-                              -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
-add_dependencies(cxxabi-test-depends libcxxabi-install-cxx-for-testing)
-
-add_custom_target(libcxxabi-install-cxxabi-for-testing
-                      DEPENDS cxxabi-headers
-                              cxxabi
-                      COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXXABI_TESTING_INSTALL_PREFIX}"
-                      COMMAND "${CMAKE_COMMAND}"
-                              -DCMAKE_INSTALL_COMPONENT=cxxabi-headers
-                              -DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
-                              -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
-                      COMMAND "${CMAKE_COMMAND}"
-                              -DCMAKE_INSTALL_COMPONENT=cxxabi
-                              -DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
-                              -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
-add_dependencies(cxxabi-test-depends libcxxabi-install-cxxabi-for-testing)
-
+set(libcxxabi_test_suite_install_targets cxx-headers cxx cxx_experimental cxx-modules cxxabi-headers cxxabi)
 if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
-  add_custom_target(libcxxabi-install-unwind-for-testing
-    DEPENDS unwind-headers
-            unwind
-    COMMAND ${CMAKE_COMMAND} -E make_directory "${LIBCXXABI_TESTING_INSTALL_PREFIX}"
-    COMMAND "${CMAKE_COMMAND}"
-            -DCMAKE_INSTALL_COMPONENT=unwind-headers
-            -DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
-            -P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
-    COMMAND "${CMAKE_COMMAND}"
-            -DCMAKE_INSTALL_COMPONENT=unwind
-            -DCMAKE_INSTALL_PREFIX="${LIBCXXABI_TESTING_INSTALL_PREFIX}"
-            -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
-  add_dependencies(cxxabi-test-depends libcxxabi-install-unwind-for-testing)
+  list(APPEND libcxxabi_test_suite_install_targets unwind-headers unwind)
 endif()
+foreach(target IN LISTS libcxxabi_test_suite_install_targets)
+  add_custom_target(libcxxabi-test-suite-install-${target} DEPENDS "${target}"
+                    COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_BINARY_DIR}"
+                                               --prefix "${LIBCXXABI_TESTING_INSTALL_PREFIX}"
+                                               --component "${target}")
+  add_dependencies(cxxabi-test-depends libcxxabi-test-suite-install-${target})
+endforeach()
 
 pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
 

>From 64a9af1b3a6e7fd128589bf4777c997057539e56 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 9 Dec 2025 16:10:12 -0500
Subject: [PATCH 2/5] Properly handle cxx_experimental

---
 libcxx/test/CMakeLists.txt    | 5 ++++-
 libcxxabi/test/CMakeLists.txt | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
index 57474f92a4bfd..58967c5f88c80 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -5,7 +5,10 @@ add_subdirectory(tools)
 # This ensures that we run the test suite against a setup that matches what we ship
 # in production as closely as possible (in terms of file paths, rpaths, etc).
 set(LIBCXX_TESTING_INSTALL_PREFIX "${LIBCXX_BINARY_DIR}/test-suite-install")
-set(libcxx_test_suite_install_targets cxx-headers cxx cxx_experimental cxx-modules)
+set(libcxx_test_suite_install_targets cxx-headers cxx cxx-modules)
+if (TARGET cxx_experimental)
+  list(APPEND libcxx_test_suite_install_targets cxx_experimental)
+endif()
 if (LIBCXX_CXX_ABI STREQUAL "libcxxabi")
   list(APPEND libcxx_test_suite_install_targets cxxabi-headers cxxabi)
 endif()
diff --git a/libcxxabi/test/CMakeLists.txt b/libcxxabi/test/CMakeLists.txt
index 021bd7cc959e2..19580d86a55e0 100644
--- a/libcxxabi/test/CMakeLists.txt
+++ b/libcxxabi/test/CMakeLists.txt
@@ -12,7 +12,10 @@ endmacro()
 # suite against it. This ensures that we run the test suite against a setup that matches
 # what we ship in production as closely as possible (in terms of file paths, rpaths, etc).
 set(LIBCXXABI_TESTING_INSTALL_PREFIX "${LIBCXXABI_BINARY_DIR}/test-suite-install")
-set(libcxxabi_test_suite_install_targets cxx-headers cxx cxx_experimental cxx-modules cxxabi-headers cxxabi)
+set(libcxxabi_test_suite_install_targets cxx-headers cxx cxx-modules cxxabi-headers cxxabi)
+if (TARGET cxx_experimental)
+  list(APPEND libcxxabi_test_suite_install_targets cxx_experimental)
+endif()
 if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
   list(APPEND libcxxabi_test_suite_install_targets unwind-headers unwind)
 endif()

>From c56b83489c7835fa2f0ad885c083b72ab8ee94e8 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 9 Dec 2025 16:29:41 -0500
Subject: [PATCH 3/5] Run test installation targets serially

---
 libcxx/test/CMakeLists.txt    | 5 ++++-
 libcxxabi/test/CMakeLists.txt | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
index 58967c5f88c80..476e9a750dcca 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -15,11 +15,14 @@ endif()
 if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
   list(APPEND libcxx_test_suite_install_targets unwind-headers unwind)
 endif()
+# Run installation targets serially to avoid race conditions between install targets
+set_property(GLOBAL PROPERTY JOB_POOLS libcxx-test-install-pool=1 APPEND)
 foreach(target IN LISTS libcxx_test_suite_install_targets)
   add_custom_target(libcxx-test-suite-install-${target} DEPENDS "${target}"
                     COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_BINARY_DIR}"
                                                --prefix "${LIBCXX_TESTING_INSTALL_PREFIX}"
-                                               --component "${target}")
+                                               --component "${target}"
+                    JOB_POOL libcxx-test-install-pool)
   add_dependencies(cxx-test-depends libcxx-test-suite-install-${target})
 endforeach()
 
diff --git a/libcxxabi/test/CMakeLists.txt b/libcxxabi/test/CMakeLists.txt
index 19580d86a55e0..b7ab626ef784b 100644
--- a/libcxxabi/test/CMakeLists.txt
+++ b/libcxxabi/test/CMakeLists.txt
@@ -19,11 +19,14 @@ endif()
 if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
   list(APPEND libcxxabi_test_suite_install_targets unwind-headers unwind)
 endif()
+# Run installation targets serially to avoid race conditions between install targets
+set_property(GLOBAL PROPERTY JOB_POOLS libcxxabi-test-install-pool=1 APPEND)
 foreach(target IN LISTS libcxxabi_test_suite_install_targets)
   add_custom_target(libcxxabi-test-suite-install-${target} DEPENDS "${target}"
                     COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_BINARY_DIR}"
                                                --prefix "${LIBCXXABI_TESTING_INSTALL_PREFIX}"
-                                               --component "${target}")
+                                               --component "${target}"
+                    JOB_POOL libcxxabi-test-install-pool)
   add_dependencies(cxxabi-test-depends libcxxabi-test-suite-install-${target})
 endforeach()
 

>From 479b053fcec4e5cf7fe27530761c0ecff7b63ab9 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 10 Dec 2025 12:33:29 -0500
Subject: [PATCH 4/5] Revert changes to add a JOB_POOL and run serially, since
 that's not the issue.

---
 libcxx/test/CMakeLists.txt    | 5 +----
 libcxxabi/test/CMakeLists.txt | 5 +----
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
index 476e9a750dcca..58967c5f88c80 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -15,14 +15,11 @@ endif()
 if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
   list(APPEND libcxx_test_suite_install_targets unwind-headers unwind)
 endif()
-# Run installation targets serially to avoid race conditions between install targets
-set_property(GLOBAL PROPERTY JOB_POOLS libcxx-test-install-pool=1 APPEND)
 foreach(target IN LISTS libcxx_test_suite_install_targets)
   add_custom_target(libcxx-test-suite-install-${target} DEPENDS "${target}"
                     COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_BINARY_DIR}"
                                                --prefix "${LIBCXX_TESTING_INSTALL_PREFIX}"
-                                               --component "${target}"
-                    JOB_POOL libcxx-test-install-pool)
+                                               --component "${target}")
   add_dependencies(cxx-test-depends libcxx-test-suite-install-${target})
 endforeach()
 
diff --git a/libcxxabi/test/CMakeLists.txt b/libcxxabi/test/CMakeLists.txt
index b7ab626ef784b..19580d86a55e0 100644
--- a/libcxxabi/test/CMakeLists.txt
+++ b/libcxxabi/test/CMakeLists.txt
@@ -19,14 +19,11 @@ endif()
 if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
   list(APPEND libcxxabi_test_suite_install_targets unwind-headers unwind)
 endif()
-# Run installation targets serially to avoid race conditions between install targets
-set_property(GLOBAL PROPERTY JOB_POOLS libcxxabi-test-install-pool=1 APPEND)
 foreach(target IN LISTS libcxxabi_test_suite_install_targets)
   add_custom_target(libcxxabi-test-suite-install-${target} DEPENDS "${target}"
                     COMMAND "${CMAKE_COMMAND}" --install "${CMAKE_BINARY_DIR}"
                                                --prefix "${LIBCXXABI_TESTING_INSTALL_PREFIX}"
-                                               --component "${target}"
-                    JOB_POOL libcxxabi-test-install-pool)
+                                               --component "${target}")
   add_dependencies(cxxabi-test-depends libcxxabi-test-suite-install-${target})
 endforeach()
 

>From 2532200914286698e344af330ed586a651501b1a Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 10 Dec 2025 12:46:44 -0500
Subject: [PATCH 5/5] Fix dependency on cxx_experimental

---
 libcxx/test/CMakeLists.txt    | 6 +++---
 libcxxabi/test/CMakeLists.txt | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
index 58967c5f88c80..8db36bcda944c 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -6,9 +6,6 @@ add_subdirectory(tools)
 # in production as closely as possible (in terms of file paths, rpaths, etc).
 set(LIBCXX_TESTING_INSTALL_PREFIX "${LIBCXX_BINARY_DIR}/test-suite-install")
 set(libcxx_test_suite_install_targets cxx-headers cxx cxx-modules)
-if (TARGET cxx_experimental)
-  list(APPEND libcxx_test_suite_install_targets cxx_experimental)
-endif()
 if (LIBCXX_CXX_ABI STREQUAL "libcxxabi")
   list(APPEND libcxx_test_suite_install_targets cxxabi-headers cxxabi)
 endif()
@@ -22,6 +19,9 @@ foreach(target IN LISTS libcxx_test_suite_install_targets)
                                                --component "${target}")
   add_dependencies(cxx-test-depends libcxx-test-suite-install-${target})
 endforeach()
+if (TARGET cxx_experimental)
+  add_dependencies(libcxx-test-suite-install-cxx cxx_experimental)
+endif()
 
 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
 set(SERIALIZED_LIT_PARAMS "# Lit parameters serialized here for llvm-lit to pick them up\n")
diff --git a/libcxxabi/test/CMakeLists.txt b/libcxxabi/test/CMakeLists.txt
index 19580d86a55e0..fadc818da2dc7 100644
--- a/libcxxabi/test/CMakeLists.txt
+++ b/libcxxabi/test/CMakeLists.txt
@@ -13,9 +13,6 @@ endmacro()
 # what we ship in production as closely as possible (in terms of file paths, rpaths, etc).
 set(LIBCXXABI_TESTING_INSTALL_PREFIX "${LIBCXXABI_BINARY_DIR}/test-suite-install")
 set(libcxxabi_test_suite_install_targets cxx-headers cxx cxx-modules cxxabi-headers cxxabi)
-if (TARGET cxx_experimental)
-  list(APPEND libcxxabi_test_suite_install_targets cxx_experimental)
-endif()
 if (LIBCXXABI_USE_LLVM_UNWINDER AND TARGET unwind)
   list(APPEND libcxxabi_test_suite_install_targets unwind-headers unwind)
 endif()
@@ -26,6 +23,9 @@ foreach(target IN LISTS libcxxabi_test_suite_install_targets)
                                                --component "${target}")
   add_dependencies(cxxabi-test-depends libcxxabi-test-suite-install-${target})
 endforeach()
+if (TARGET cxx_experimental)
+  add_dependencies(libcxxabi-test-suite-install-cxx cxx_experimental)
+endif()
 
 pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
 



More information about the libcxx-commits mailing list