[libcxx-commits] [libcxx] [libc++] Compose the test suite Lit site config from harness and installation substitutions (PR #209638)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jul 16 09:56:59 PDT 2026
https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/209638
>From 7a9669daf99eab79efedaa551de4742cab2357e7 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 14 Jul 2026 15:44:29 -0400
Subject: [PATCH] [libc++] Compose the test suite Lit site config from harness
and installation substitutions
This patch restructures how libc++'s Lit site config is generated. Instead
of relying on the user-selected configuration file to include the CMake
bridge, it composes a site configuration from multiple independent bits.
Importantly, it splits substitutions that pertain to the harness setup
(e.g. where to find Python) and substitutions that pertain to libc++
itself (e.g. the path to libc++ headers). This split and the top-level
composition of a site config file are incremental steps towards decoupling
the test suite from libc++'s own build.
---
libcxx/test/CMakeLists.txt | 23 +++++++++++++++----
.../test/configs/amdgpu-libc++-shared.cfg.in | 2 --
.../test/configs/apple-libc++-shared.cfg.in | 2 --
.../test/configs/apple-libc++-system.cfg.in | 2 --
.../configs/armv7m-picolibc-libc++.cfg.in | 2 --
...ge.cfg.in => harness-configuration.cfg.in} | 15 ++++--------
libcxx/test/configs/ibm-libc++-shared.cfg.in | 2 --
.../test/configs/libcxx-substitutions.cfg.in | 13 +++++++++++
libcxx/test/configs/lit.site.cfg.in | 11 +++++++++
.../test/configs/llvm-libc++-android.cfg.in | 2 --
.../test/configs/llvm-libc++-llvm-libc.cfg.in | 2 --
libcxx/test/configs/llvm-libc++-mingw.cfg.in | 2 --
.../configs/llvm-libc++-shared-clangcl.cfg.in | 2 --
.../configs/llvm-libc++-shared-gcc.cfg.in | 2 --
...-libc++-shared-no-vcruntime-clangcl.cfg.in | 2 --
libcxx/test/configs/llvm-libc++-shared.cfg.in | 2 --
.../configs/llvm-libc++-static-clangcl.cfg.in | 2 --
libcxx/test/configs/llvm-libc++-static.cfg.in | 2 --
.../test/configs/nvptx-libc++-shared.cfg.in | 2 --
libcxx/test/configs/stdlib-libstdc++.cfg.in | 2 --
libcxx/test/configs/stdlib-native.cfg.in | 2 --
21 files changed, 47 insertions(+), 49 deletions(-)
rename libcxx/test/configs/{cmake-bridge.cfg.in => harness-configuration.cfg.in} (52%)
create mode 100644 libcxx/test/configs/libcxx-substitutions.cfg.in
create mode 100644 libcxx/test/configs/lit.site.cfg.in
diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
index 39d383922e1df..8fd34c086a992 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -55,12 +55,27 @@ serialize_lit_params_list(SERIALIZED_LIT_PARAMS LIBCXX_TEST_PARAMS)
include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuite
-configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/cmake-bridge.cfg.in"
- "${CMAKE_CURRENT_BINARY_DIR}/cmake-bridge.cfg"
- @ONLY)
+# The test suite is driven by a generated lit.site.cfg that loads the various other configuration
+# files needed by it. In order:
+# - The harness configuration, which defines substitutions needed for the test suite's own function
+# (e.g. the path to Python).
+# - The libc++ substitutions file, which adds libc++ specific substitutions, such as the location of
+# include paths. Those are needed for libc++ specific tests.
+# - The user-selected site configuration, which defines substitutions that determine e.g. how to
+# build, link and run the tests.
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/harness-configuration.cfg.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/harness-configuration.cfg"
+ @ONLY)
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/configs/libcxx-substitutions.cfg.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/libcxx-substitutions.cfg"
+ @ONLY)
+string(REGEX REPLACE "\\.in$" "" _resolved_config_name "${LIBCXX_TEST_CONFIG}")
+get_filename_component(_resolved_config_name "${_resolved_config_name}" NAME)
+set(LIBCXX_RESOLVED_TEST_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/${_resolved_config_name}")
+configure_file("${LIBCXX_TEST_CONFIG}" "${LIBCXX_RESOLVED_TEST_CONFIG}" @ONLY)
configure_lit_site_cfg(
- "${LIBCXX_TEST_CONFIG}"
+ "${CMAKE_CURRENT_SOURCE_DIR}/configs/lit.site.cfg.in"
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
MAIN_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py")
diff --git a/libcxx/test/configs/amdgpu-libc++-shared.cfg.in b/libcxx/test/configs/amdgpu-libc++-shared.cfg.in
index 80c80ebaa8bd0..b34eced0bf1e0 100644
--- a/libcxx/test/configs/amdgpu-libc++-shared.cfg.in
+++ b/libcxx/test/configs/amdgpu-libc++-shared.cfg.in
@@ -1,5 +1,3 @@
-lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
-
config.substitutions.append(('%{flags}',
f'--target={config.target_triple} -Wno-multi-gpu -flto -mcpu=native'))
config.substitutions.append(('%{compile_flags}',
diff --git a/libcxx/test/configs/apple-libc++-shared.cfg.in b/libcxx/test/configs/apple-libc++-shared.cfg.in
index a361b2b8adc00..e6d61dffbbd97 100644
--- a/libcxx/test/configs/apple-libc++-shared.cfg.in
+++ b/libcxx/test/configs/apple-libc++-shared.cfg.in
@@ -14,8 +14,6 @@
# issues since the upstream libc++ does not contain all the symbols provided by
# the system library.
-lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
-
import os, site
site.addsitedir(os.path.join('@LIBCXX_SOURCE_DIR@', 'utils'))
import libcxx.test.params, libcxx.test.config, libcxx.test.dsl
diff --git a/libcxx/test/configs/apple-libc++-system.cfg.in b/libcxx/test/configs/apple-libc++-system.cfg.in
index e87f920e7b93d..3bc9fe8956f14 100644
--- a/libcxx/test/configs/apple-libc++-system.cfg.in
+++ b/libcxx/test/configs/apple-libc++-system.cfg.in
@@ -7,8 +7,6 @@ import os, site
site.addsitedir(os.path.join('@LIBCXX_SOURCE_DIR@', 'utils'))
import libcxx.test.params, libcxx.test.config, libcxx.test.dsl
-lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
-
config.substitutions.append(('%{flags}',
'-isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else ''
))
diff --git a/libcxx/test/configs/armv7m-picolibc-libc++.cfg.in b/libcxx/test/configs/armv7m-picolibc-libc++.cfg.in
index f0782c28ce3e5..181263e95d62b 100644
--- a/libcxx/test/configs/armv7m-picolibc-libc++.cfg.in
+++ b/libcxx/test/configs/armv7m-picolibc-libc++.cfg.in
@@ -1,5 +1,3 @@
-lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
-
libc_linker_script = '@CMAKE_INSTALL_PREFIX@/lib/picolibcpp.ld'
config.substitutions.append(('%{flags}', '--sysroot=@CMAKE_INSTALL_PREFIX@'))
diff --git a/libcxx/test/configs/cmake-bridge.cfg.in b/libcxx/test/configs/harness-configuration.cfg.in
similarity index 52%
rename from libcxx/test/configs/cmake-bridge.cfg.in
rename to libcxx/test/configs/harness-configuration.cfg.in
index 20b7c1e9bc357..c527d60c64af5 100644
--- a/libcxx/test/configs/cmake-bridge.cfg.in
+++ b/libcxx/test/configs/harness-configuration.cfg.in
@@ -4,11 +4,11 @@
#
# This file performs the bridge between the CMake configuration and the Lit
-# configuration files by setting up the LitConfig object and various Lit
-# substitutions from CMake variables.
+# configuration files by setting up the LitConfig object and the Lit substitutions
+# that are independent of the library under test.
#
-# Individual configuration files can take advantage of this bridge by
-# loading the file and then setting up the remaining Lit substitutions.
+# It is loaded by the generated lit.site.cfg, before the library-under-test
+# substitutions (libcxx-substitutions.cfg) and the site configuration file.
#
import os, site
@@ -25,13 +25,6 @@ config.recursiveExpansionLimit = 10
config.test_exec_root = os.path.join('@LIBCXX_BINARY_DIR@', 'test')
# Add substitutions for bootstrapping the test suite configuration
-config.substitutions.append(('%{bin-dir}', '@LIBCXX_BINARY_DIR@'))
config.substitutions.append(('%{libcxx-dir}', '@LIBCXX_SOURCE_DIR@'))
-config.substitutions.append(('%{install-prefix}', '@LIBCXX_TESTING_INSTALL_PREFIX@'))
-config.substitutions.append(('%{include-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/@LIBCXX_INSTALL_INCLUDE_DIR@'))
-config.substitutions.append(('%{target-include-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/@LIBCXX_INSTALL_INCLUDE_TARGET_DIR@'))
-config.substitutions.append(('%{lib-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/@LIBCXX_INSTALL_LIBRARY_DIR@'))
-config.substitutions.append(('%{module-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/@LIBCXX_INSTALL_MODULES_DIR@'))
-config.substitutions.append(('%{test-tools-dir}', '@LIBCXX_TEST_TOOLS_PATH@'))
config.substitutions.append(('%{benchmark_flags}', '-I @LIBCXX_BINARY_DIR@/test/benchmarks/google-benchmark/include -L @LIBCXX_BINARY_DIR@/test/benchmarks/google-benchmark/lib -L @LIBCXX_BINARY_DIR@/test/benchmarks/google-benchmark/lib64 -l benchmark'))
config.substitutions.append(("%{python}", shlex.quote(sys.executable)))
diff --git a/libcxx/test/configs/ibm-libc++-shared.cfg.in b/libcxx/test/configs/ibm-libc++-shared.cfg.in
index 863b1ae85b0ed..3fcf64e3537e0 100644
--- a/libcxx/test/configs/ibm-libc++-shared.cfg.in
+++ b/libcxx/test/configs/ibm-libc++-shared.cfg.in
@@ -2,8 +2,6 @@
# AIX using a shared library.
#
-lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
-
import lit.util
if lit.util.isAIXTriple(config.target_triple):
# Add the AIX version to the triple here because there currently isn't a good
diff --git a/libcxx/test/configs/libcxx-substitutions.cfg.in b/libcxx/test/configs/libcxx-substitutions.cfg.in
new file mode 100644
index 0000000000000..a74ff013219b2
--- /dev/null
+++ b/libcxx/test/configs/libcxx-substitutions.cfg.in
@@ -0,0 +1,13 @@
+ at AUTO_GEN_COMMENT@
+
+#
+# This file sets up Lit substitutions that describe paths related to libc++'s installation, which
+# are used by libc++ specific tests.
+#
+config.substitutions.append(('%{bin-dir}', '@LIBCXX_BINARY_DIR@'))
+config.substitutions.append(('%{install-prefix}', '@LIBCXX_TESTING_INSTALL_PREFIX@'))
+config.substitutions.append(('%{include-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/@LIBCXX_INSTALL_INCLUDE_DIR@'))
+config.substitutions.append(('%{target-include-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/@LIBCXX_INSTALL_INCLUDE_TARGET_DIR@'))
+config.substitutions.append(('%{lib-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/@LIBCXX_INSTALL_LIBRARY_DIR@'))
+config.substitutions.append(('%{module-dir}', '@LIBCXX_TESTING_INSTALL_PREFIX@/@LIBCXX_INSTALL_MODULES_DIR@'))
+config.substitutions.append(('%{test-tools-dir}', '@LIBCXX_TEST_TOOLS_PATH@'))
diff --git a/libcxx/test/configs/lit.site.cfg.in b/libcxx/test/configs/lit.site.cfg.in
new file mode 100644
index 0000000000000..148bf5534453b
--- /dev/null
+++ b/libcxx/test/configs/lit.site.cfg.in
@@ -0,0 +1,11 @@
+ at AUTO_GEN_COMMENT@
+
+#
+# This is the top-level Lit site configuration. It loads, in order:
+# 1. the harness configuration,
+# 2. the substitutions that are specific to libc++, and
+# 3. the chosen site configuration file, which describes how to build, link and run the tests.
+#
+lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/harness-configuration.cfg')
+lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/libcxx-substitutions.cfg')
+lit_config.load_config(config, '@LIBCXX_RESOLVED_TEST_CONFIG@')
diff --git a/libcxx/test/configs/llvm-libc++-android.cfg.in b/libcxx/test/configs/llvm-libc++-android.cfg.in
index 96c952d6bbc19..8b149207d61d4 100644
--- a/libcxx/test/configs/llvm-libc++-android.cfg.in
+++ b/libcxx/test/configs/llvm-libc++-android.cfg.in
@@ -1,8 +1,6 @@
# This testing configuration handles running the test suite against LLVM's
# libc++ using adb on Android.
-lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
-
import re
import site
diff --git a/libcxx/test/configs/llvm-libc++-llvm-libc.cfg.in b/libcxx/test/configs/llvm-libc++-llvm-libc.cfg.in
index cae8a8007214e..883fa82132227 100644
--- a/libcxx/test/configs/llvm-libc++-llvm-libc.cfg.in
+++ b/libcxx/test/configs/llvm-libc++-llvm-libc.cfg.in
@@ -1,8 +1,6 @@
# This testing configuration handles running the test suite against LLVM's libc++
# using a static library.
-lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
-
config.substitutions.append(('%{flags}',
'-pthread' + (' -isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else '')
))
diff --git a/libcxx/test/configs/llvm-libc++-mingw.cfg.in b/libcxx/test/configs/llvm-libc++-mingw.cfg.in
index 44731713b427b..f96d4b12c918c 100644
--- a/libcxx/test/configs/llvm-libc++-mingw.cfg.in
+++ b/libcxx/test/configs/llvm-libc++-mingw.cfg.in
@@ -1,8 +1,6 @@
# This testing configuration handles running the test suite against LLVM's libc++
# using either a DLL or a static library, with MinGW/Clang on Windows.
-lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
-
config.substitutions.append(('%{flags}', ''))
config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I %{target-include-dir} -I %{include-dir} -I %{libcxx-dir}/test/support'
diff --git a/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in b/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in
index e6186a7c73c3a..5196ca32479ac 100644
--- a/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in
+++ b/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in
@@ -1,8 +1,6 @@
# This testing configuration handles running the test suite against LLVM's libc++
# using a DLL, with Clang-cl on Windows.
-lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
-
dbg_include = ''
runtime_library = '@CMAKE_MSVC_RUNTIME_LIBRARY@'
if runtime_library == '' or runtime_library.endswith('DLL'):
diff --git a/libcxx/test/configs/llvm-libc++-shared-gcc.cfg.in b/libcxx/test/configs/llvm-libc++-shared-gcc.cfg.in
index 1b4ddc299759e..ad31e2811a8ab 100644
--- a/libcxx/test/configs/llvm-libc++-shared-gcc.cfg.in
+++ b/libcxx/test/configs/llvm-libc++-shared-gcc.cfg.in
@@ -2,8 +2,6 @@
# using a shared library, with GCC. This is done differently from Clang because
# we need to explicitly link against libm for some tests with GCC.
-lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
-
config.substitutions.append(('%{flags}', '-pthread'))
config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I %{target-include-dir} -I %{include-dir} -I %{libcxx-dir}/test/support'
diff --git a/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in b/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in
index 476c5ca715a65..ce142b1a9d644 100644
--- a/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in
+++ b/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in
@@ -2,8 +2,6 @@
# using a DLL, with Clang-cl on Windows. This variant sets _HAS_EXCEPTIONS = 0
# which removes exception class definitions from the vcruntime.
-lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
-
dbg_include = ''
runtime_library = '@CMAKE_MSVC_RUNTIME_LIBRARY@'
if runtime_library == '' or runtime_library.endswith('DLL'):
diff --git a/libcxx/test/configs/llvm-libc++-shared.cfg.in b/libcxx/test/configs/llvm-libc++-shared.cfg.in
index 6d4a3836b2baa..71e56e732e796 100644
--- a/libcxx/test/configs/llvm-libc++-shared.cfg.in
+++ b/libcxx/test/configs/llvm-libc++-shared.cfg.in
@@ -1,8 +1,6 @@
# This testing configuration handles running the test suite against LLVM's libc++
# using a shared library.
-lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
-
config.substitutions.append(('%{flags}',
'-pthread' + (' -isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else '')
))
diff --git a/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in b/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in
index 2f2b420d32190..4be1e1afa1c5b 100644
--- a/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in
+++ b/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in
@@ -1,8 +1,6 @@
# This testing configuration handles running the test suite against LLVM's libc++
# using a static library, with Clang-cl on Windows.
-lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
-
dbg_include = ''
runtime_library = '@CMAKE_MSVC_RUNTIME_LIBRARY@'
if runtime_library == '' or runtime_library.endswith('DLL'):
diff --git a/libcxx/test/configs/llvm-libc++-static.cfg.in b/libcxx/test/configs/llvm-libc++-static.cfg.in
index 45a44c13e76eb..c6a6ab2398079 100644
--- a/libcxx/test/configs/llvm-libc++-static.cfg.in
+++ b/libcxx/test/configs/llvm-libc++-static.cfg.in
@@ -1,8 +1,6 @@
# This testing configuration handles running the test suite against LLVM's libc++
# using a static library.
-lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
-
config.substitutions.append(('%{flags}',
'-pthread' + (' -isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else '')
))
diff --git a/libcxx/test/configs/nvptx-libc++-shared.cfg.in b/libcxx/test/configs/nvptx-libc++-shared.cfg.in
index e07ed35da4d5a..c8dcac55e3596 100644
--- a/libcxx/test/configs/nvptx-libc++-shared.cfg.in
+++ b/libcxx/test/configs/nvptx-libc++-shared.cfg.in
@@ -1,5 +1,3 @@
-lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
-
config.substitutions.append(('%{flags}',
f'--target={config.target_triple} -Wno-multi-gpu -flto -march=native'))
config.substitutions.append(('%{compile_flags}',
diff --git a/libcxx/test/configs/stdlib-libstdc++.cfg.in b/libcxx/test/configs/stdlib-libstdc++.cfg.in
index 1a4b47cb1335b..429b1fe153938 100644
--- a/libcxx/test/configs/stdlib-libstdc++.cfg.in
+++ b/libcxx/test/configs/stdlib-libstdc++.cfg.in
@@ -13,8 +13,6 @@
# --param stdlib=libstdc++
#
-lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
-
import os, site
site.addsitedir(os.path.join('@LIBCXX_SOURCE_DIR@', 'utils'))
import libcxx.test.params, libcxx.test.config, libcxx.test.dsl
diff --git a/libcxx/test/configs/stdlib-native.cfg.in b/libcxx/test/configs/stdlib-native.cfg.in
index b827155fd579a..3f64e37cdbcfa 100644
--- a/libcxx/test/configs/stdlib-native.cfg.in
+++ b/libcxx/test/configs/stdlib-native.cfg.in
@@ -4,8 +4,6 @@
# default when no special compiler flags are provided.
#
-lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
-
config.substitutions.append(('%{flags}',
'-pthread' + (' -isysroot {}'.format('@CMAKE_OSX_SYSROOT@') if '@CMAKE_OSX_SYSROOT@' else '')
))
More information about the libcxx-commits
mailing list