[clang] f875a73 - [llvm-lit] Add Windows .cmd wrapper to make llvm-lit directly runnable (#155226)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 29 01:54:24 PDT 2025
Author: Omair Javaid
Date: 2025-08-29T13:54:21+05:00
New Revision: f875a73af958bd1ed6c39849c7ae90371cd25ccb
URL: https://github.com/llvm/llvm-project/commit/f875a73af958bd1ed6c39849c7ae90371cd25ccb
DIFF: https://github.com/llvm/llvm-project/commit/f875a73af958bd1ed6c39849c7ae90371cd25ccb.diff
LOG: [llvm-lit] Add Windows .cmd wrapper to make llvm-lit directly runnable (#155226)
On Linux/Mac, `llvm-lit` is configured with a shebang and made
executable so tools like LNT and the test-suite can invoke it directly.
On Windows the build only produces `llvm-lit.py` which cannot be used as
a standalone executable. This caused problems when running the LLVM
test-suite via LNT or buildbots.
This change introduces a new template file `llvm-lit.cmd.in` and updates
`llvm/utils/llvm-lit/CMakeLists.txt` so that a corresponding
`llvm-lit.cmd` is generated in the `build/bin` directory (for both
single-config and multi-config generators). The wrapper simply invokes
the configured Python interpreter on the adjacent `llvm-lit.py` and
propagates the exit code.
This ensures that `llvm-lit` can be used as a direct executable on
Windows just like on Linux without requiring external wrappers or
modifications in buildbot scripts or LNT.
Added:
llvm/utils/llvm-lit/llvm-lit.cmd.in
Modified:
clang/test/utils/update_cc_test_checks/lit.local.cfg
llvm/utils/llvm-lit/CMakeLists.txt
Removed:
################################################################################
diff --git a/clang/test/utils/update_cc_test_checks/lit.local.cfg b/clang/test/utils/update_cc_test_checks/lit.local.cfg
index f2810fa18c8fc..d7cc78d8f67fe 100644
--- a/clang/test/utils/update_cc_test_checks/lit.local.cfg
+++ b/clang/test/utils/update_cc_test_checks/lit.local.cfg
@@ -39,7 +39,7 @@ else:
lit = config.llvm_external_lit
else:
lit = shell_quote(
- glob.glob(os.path.join(config.llvm_tools_dir, "llvm-lit*"))[0]
+ os.path.join(config.llvm_tools_dir, "llvm-lit.py" if os.name == "nt" else "llvm-lit")
)
python = shell_quote(config.python_executable)
config.substitutions.append(
diff --git a/llvm/utils/llvm-lit/CMakeLists.txt b/llvm/utils/llvm-lit/CMakeLists.txt
index 895fa25f189de..8ee8e98541ce4 100644
--- a/llvm/utils/llvm-lit/CMakeLists.txt
+++ b/llvm/utils/llvm-lit/CMakeLists.txt
@@ -35,6 +35,14 @@ if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
llvm-lit.in
${bi}
)
+ if (WIN32)
+ string(REPLACE ${CMAKE_CFG_INTDIR} ${BUILD_MODE} bi_dir ${LIT_BASE_DIR})
+ configure_file(
+ llvm-lit.cmd.in
+ ${bi_dir}/llvm-lit.cmd
+ @ONLY
+ NEWLINE_STYLE DOS)
+ endif()
endforeach()
else()
set(BUILD_MODE .)
@@ -42,4 +50,11 @@ else()
llvm-lit.in
${LIT_BASE_DIR}/${LIT_FILE_NAME}
)
+ if (WIN32)
+ configure_file(
+ llvm-lit.cmd.in
+ ${LIT_BASE_DIR}/llvm-lit.cmd
+ @ONLY
+ NEWLINE_STYLE DOS)
+ endif()
endif()
diff --git a/llvm/utils/llvm-lit/llvm-lit.cmd.in b/llvm/utils/llvm-lit/llvm-lit.cmd.in
new file mode 100644
index 0000000000000..a18d5316cc8d6
--- /dev/null
+++ b/llvm/utils/llvm-lit/llvm-lit.cmd.in
@@ -0,0 +1,3 @@
+ at echo off
+"@Python3_EXECUTABLE@" "%~dp0 at LIT_FILE_NAME@" %*
+exit /b %errorlevel%
More information about the cfe-commits
mailing list