[clang] [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 09:42:03 PDT 2025
https://github.com/omjavaid updated https://github.com/llvm/llvm-project/pull/155226
>From 854c011d92352ffc913644ee4e7aee8f73376892 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 1/2] 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%
>From af841b1d371cbd9094871fd6044a5e0b35035295 Mon Sep 17 00:00:00 2001
From: Muhammad Omair Javaid <omair.javaid at linaro.org>
Date: Mon, 25 Aug 2025 15:43:09 +0500
Subject: [PATCH 2/2] Fix failure in update_cc_test_checks
---
clang/test/utils/update_cc_test_checks/lit.local.cfg | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
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..d3151484254c9 100644
--- a/clang/test/utils/update_cc_test_checks/lit.local.cfg
+++ b/clang/test/utils/update_cc_test_checks/lit.local.cfg
@@ -38,9 +38,10 @@ else:
if config.llvm_external_lit:
lit = config.llvm_external_lit
else:
- lit = shell_quote(
- glob.glob(os.path.join(config.llvm_tools_dir, "llvm-lit*"))[0]
- )
+ if os.name == "nt":
+ lit = shell_quote(os.path.join(config.llvm_tools_dir, "llvm-lit.py"))
+ else:
+ lit = shell_quote(os.path.join(config.llvm_tools_dir, "llvm-lit"))
python = shell_quote(config.python_executable)
config.substitutions.append(
(
More information about the llvm-commits
mailing list