Skip to content

Commit 78d649a

Browse files
authored
[libc++][lit] Allow overriding the executor for tests (#66545)
This is useful when trying to run multiple tests with different arguments to the executor script. This is needed in my case since I do not know the correct ssh connection arguments when building libc++. The testing script I have spawns multiple QEMU instances that listen on a given port on localhost and runs lit with the --num-shards/--run-shard argument. In order to connect each shard to the right QEMU instances I need to customize the arguments passed to ssh.py (--extra-ssh-args and --extra-scp-args) but can't do this at configure time since the target port is only known when running the tests but not when calling CMake. This change allows me to pass `executor=ssh.py <args>` to lit once I know the right hostname/port for running the tests. This also deprecates the `LIB{CXX,CXXABI,UNWIND}_EXECUTOR` CMake variable as the same can be achieved by adding `executor=...` to the `LIB{CXX,CXXABI,UNWIND}_TEST_PARAMS` variable.
1 parent b29b6cc commit 78d649a

File tree

9 files changed

+34
-14
lines changed

9 files changed

+34
-14
lines changed

clang/cmake/caches/CrossWinToARMLinux.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ if(DEFINED REMOTE_TEST_HOST)
162162
"\\\"${Python3_EXECUTABLE}\\\" \\\"${LLVM_PROJECT_DIR}/llvm/utils/remote-exec.py\\\" --host=${REMOTE_TEST_USER}@${REMOTE_TEST_HOST}"
163163
CACHE STRING "")
164164

165-
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBUNWIND_EXECUTOR "${DEFAULT_TEST_EXECUTOR}" CACHE STRING "")
166-
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_EXECUTOR "${DEFAULT_TEST_EXECUTOR}" CACHE STRING "")
167-
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_EXECUTOR "${DEFAULT_TEST_EXECUTOR}" CACHE STRING "")
165+
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBUNWIND_TEST_PARAMS "${RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_TEST_PARAMS} 'executor=${DEFAULT_TEST_EXECUTOR}'" CACHE STRING "")
166+
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_TEST_PARAMS "${RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_TEST_PARAMS} 'executor=${DEFAULT_TEST_EXECUTOR}'" CACHE STRING "")
167+
set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_TEST_PARAMS "${RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_TEST_PARAMS} 'executor=${DEFAULT_TEST_EXECUTOR}'" CACHE STRING "")
168168
endif()
169169

170170
set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")

libcxx/docs/ReleaseNotes/18.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,8 @@ ABI Affecting Changes
134134

135135
Build System Changes
136136
--------------------
137+
138+
- The ``LIBCXX_EXECUTOR`` CMake variable has been deprecated. If you are relying on this, the new replacement is
139+
passing ``-Dexecutor=...`` to ``llvm-lit``. Alternatively, this flag can be made persistent in the generated test
140+
configuration file by passing ``-DLIBCXX_TEST_PARAMS=executor=...``. This also applies to the ``LIBUWIND_EXECTOR``
141+
and ``LIBCXXABI_EXECUTOR`` CMake variables. LLVM 19 will completely remove support for the ``*_EXECUTOR`` variables.

libcxx/test/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@ if (NOT LIBCXX_CXX_ABI_LIBRARY_PATH)
66
"The path to libc++abi library.")
77
endif()
88

9-
set(LIBCXX_EXECUTOR "\\\"${Python3_EXECUTABLE}\\\" ${CMAKE_CURRENT_LIST_DIR}/../utils/run.py" CACHE STRING
10-
"Executor to use when running tests.")
11-
129
set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
1310
set(SERIALIZED_LIT_PARAMS "# Lit parameters serialized here for llvm-lit to pick them up\n")
1411

1512
macro(serialize_lit_param param value)
1613
string(APPEND SERIALIZED_LIT_PARAMS "config.${param} = ${value}\n")
1714
endmacro()
1815

16+
if (LIBCXX_EXECUTOR)
17+
message(DEPRECATION "LIBCXX_EXECUTOR is deprecated, please add executor=... to LIBCXX_TEST_PARAMS")
18+
serialize_lit_param(executor "\"${LIBCXX_EXECUTOR}\"")
19+
endif()
20+
1921
if (NOT LIBCXX_ENABLE_EXCEPTIONS)
2022
serialize_lit_param(enable_exceptions False)
2123
endif()

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ config.substitutions.append(('%{include}', '@LIBCXX_GENERATED_INCLUDE_DIR@'))
3030
config.substitutions.append(('%{target-include}', '@LIBCXX_GENERATED_INCLUDE_TARGET_DIR@'))
3131
config.substitutions.append(('%{lib}', '@LIBCXX_LIBRARY_DIR@'))
3232
config.substitutions.append(('%{module}', '@LIBCXX_GENERATED_MODULE_DIR@'))
33-
config.substitutions.append(('%{executor}', '@LIBCXX_EXECUTOR@'))
3433
config.substitutions.append(('%{test-tools}', '@LIBCXX_TEST_TOOLS_PATH@'))
3534

3635
# The test needs to manually rebuild the module. The compiler flags used in the

libcxx/utils/libcxx/test/params.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
#
77
# ===----------------------------------------------------------------------===##
8+
import sys
9+
import re
10+
from pathlib import Path
811

912
from libcxx.test.dsl import *
1013
from libcxx.test.features import _isMSVC
11-
import re
14+
1215

1316
_warningFlags = [
1417
"-Werror",
@@ -314,5 +317,12 @@ def getStdFlag(cfg, std):
314317
AddCompileFlag("-D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES"),
315318
],
316319
),
320+
Parameter(
321+
name="executor",
322+
type=str,
323+
default=f"{sys.executable} {Path(__file__).resolve().parent.parent.parent / 'run.py'}",
324+
help="Custom executor to use instead of the configured default.",
325+
actions=lambda executor: [AddSubstitution("%{executor}", executor)],
326+
)
317327
]
318328
# fmt: on

libcxxabi/test/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ macro(pythonize_bool var)
88
endmacro()
99

1010
pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
11-
set(LIBCXXABI_EXECUTOR "\\\"${Python3_EXECUTABLE}\\\" ${LIBCXXABI_LIBCXX_PATH}/utils/run.py" CACHE STRING
12-
"Executor to use when running tests.")
1311

1412
if (LIBCXXABI_ENABLE_SHARED)
1513
set(LIBCXXABI_TEST_DEPS cxxabi_shared)
@@ -29,6 +27,11 @@ macro(serialize_lit_param param value)
2927
string(APPEND SERIALIZED_LIT_PARAMS "config.${param} = ${value}\n")
3028
endmacro()
3129

30+
if (LIBCXXABI_EXECUTOR)
31+
message(DEPRECATION "LIBCXXABI_EXECUTOR is deprecated, please add executor=... to LIBCXXABI_TEST_PARAMS")
32+
serialize_lit_param(executor "\"${LIBCXXABI_EXECUTOR}\"")
33+
endif()
34+
3235
if (NOT LIBCXXABI_ENABLE_EXCEPTIONS)
3336
serialize_lit_param(enable_exceptions False)
3437
endif()

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ config.substitutions.append(('%{include}', '@LIBCXXABI_SOURCE_DIR@/include'))
3232
config.substitutions.append(('%{cxx-include}', '@LIBCXXABI_HEADER_DIR@/include/c++/v1'))
3333
config.substitutions.append(('%{cxx-target-include}', '@LIBCXXABI_HEADER_DIR@/include/%{triple}/c++/v1'))
3434
config.substitutions.append(('%{lib}', '@LIBCXXABI_LIBRARY_DIR@'))
35-
config.substitutions.append(('%{executor}', '@LIBCXXABI_EXECUTOR@'))
3635

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

libunwind/test/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ endmacro()
1010
pythonize_bool(LIBUNWIND_ENABLE_CET)
1111
pythonize_bool(LIBUNWIND_ENABLE_THREADS)
1212
pythonize_bool(LIBUNWIND_USES_ARM_EHABI)
13-
set(LIBUNWIND_EXECUTOR "\\\"${Python3_EXECUTABLE}\\\" ${LIBUNWIND_LIBCXX_PATH}/utils/run.py" CACHE STRING
14-
"Executor to use when running tests.")
1513

1614
set(AUTO_GEN_COMMENT "## Autogenerated by libunwind configuration.\n# Do not edit!")
1715
set(SERIALIZED_LIT_PARAMS "# Lit parameters serialized here for llvm-lit to pick them up\n")
@@ -20,6 +18,11 @@ macro(serialize_lit_param param value)
2018
string(APPEND SERIALIZED_LIT_PARAMS "config.${param} = ${value}\n")
2119
endmacro()
2220

21+
if (LIBUNWIND_EXECUTOR)
22+
message(DEPRECATION "LIBUNWIND_EXECUTOR is deprecated, please add executor=... to LIBUNWIND_TEST_PARAMS")
23+
serialize_lit_param(executor "\"${LIBUNWIND_EXECUTOR}\"")
24+
endif()
25+
2326
serialize_lit_param(enable_experimental False)
2427

2528
if (LLVM_USE_SANITIZER)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,5 @@ if not @LIBUNWIND_ENABLE_THREADS@:
3131
# Add substitutions for bootstrapping the test suite configuration
3232
import shlex
3333
config.substitutions.append(('%{cxx}', shlex.quote('@CMAKE_CXX_COMPILER@')))
34-
config.substitutions.append(('%{executor}', '@LIBUNWIND_EXECUTOR@'))
3534
config.substitutions.append(('%{include}', '@LIBUNWIND_SOURCE_DIR@/include'))
3635
config.substitutions.append(('%{lib}', '@LIBUNWIND_LIBRARY_DIR@'))

0 commit comments

Comments
 (0)