Skip to content

Commit f875a73

Browse files
authored
[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.
1 parent 072a003 commit f875a73

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

clang/test/utils/update_cc_test_checks/lit.local.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ else:
3939
lit = config.llvm_external_lit
4040
else:
4141
lit = shell_quote(
42-
glob.glob(os.path.join(config.llvm_tools_dir, "llvm-lit*"))[0]
42+
os.path.join(config.llvm_tools_dir, "llvm-lit.py" if os.name == "nt" else "llvm-lit")
4343
)
4444
python = shell_quote(config.python_executable)
4545
config.substitutions.append(

llvm/utils/llvm-lit/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,26 @@ if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
3535
llvm-lit.in
3636
${bi}
3737
)
38+
if (WIN32)
39+
string(REPLACE ${CMAKE_CFG_INTDIR} ${BUILD_MODE} bi_dir ${LIT_BASE_DIR})
40+
configure_file(
41+
llvm-lit.cmd.in
42+
${bi_dir}/llvm-lit.cmd
43+
@ONLY
44+
NEWLINE_STYLE DOS)
45+
endif()
3846
endforeach()
3947
else()
4048
set(BUILD_MODE .)
4149
configure_file(
4250
llvm-lit.in
4351
${LIT_BASE_DIR}/${LIT_FILE_NAME}
4452
)
53+
if (WIN32)
54+
configure_file(
55+
llvm-lit.cmd.in
56+
${LIT_BASE_DIR}/llvm-lit.cmd
57+
@ONLY
58+
NEWLINE_STYLE DOS)
59+
endif()
4560
endif()

llvm/utils/llvm-lit/llvm-lit.cmd.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
"@Python3_EXECUTABLE@" "%~dp0@LIT_FILE_NAME@" %*
3+
exit /b %errorlevel%

0 commit comments

Comments
 (0)