[llvm] [llvm-lit] Add Windows .cmd wrapper to make llvm-lit directly runnable (PR #155226)
Omair Javaid via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 25 02:13:41 PDT 2025
https://github.com/omjavaid created https://github.com/llvm/llvm-project/pull/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.
>From 937b9e8bdb598437f4934b7203364056119794e3 Mon Sep 17 00:00:00 2001
From: Muhammad Omair Javaid <omair.javaid at linaro.org>
Date: Sun, 24 Aug 2025 23:04:34 +0500
Subject: [PATCH] Generate llvm-lit.cmd on Windows builds
This commit adds a Windows batch wrapper llvm-lit.cmd alongside
llvm-lit.py in the build\bin directory. This allows tools such as
LNT and the llvm-test-suite buildbot to invoke llvm-lit as an exe
similar to Linux/Mac behavior where llvm-lit is directly executable
due to the shebang line. The llvm-lit.cmd will dispatch llvm-lit.py
to the Python interpreter detected by CMake and pass through all args.
---
llvm/utils/llvm-lit/CMakeLists.txt | 15 +++++++++++++++
llvm/utils/llvm-lit/llvm-lit.cmd.in | 3 +++
2 files changed, 18 insertions(+)
create mode 100644 llvm/utils/llvm-lit/llvm-lit.cmd.in
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 llvm-commits
mailing list