[llvm] [bazel] Keep lit tests on the platform-default runfiles mode (PR #228446)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 2 07:04:47 PDT 2026
https://github.com/UebelAndre created https://github.com/llvm/llvm-project/pull/228446
rules_python 1.9.0 made `--enable_runfiles=true` the default for every py_binary/py_test on Windows, applied through a per-target transition (python/private/py_executable.bzl, `_add_config_setting_defaults`). This caused the transitioned value differs from the top-level one, every lit test gets an `-ST-<hash>` output directory, running into Windows `MAX_PATH` issues resulting in failing tests with
```
Could not create process (...\mlir\mlir-opt.exe) due to
[WinError 267] The directory name is invalid
```
This change relies on the escape hatch from this transition by setting `@rules_python//command_line_option:enable_runfiles` to `INHERIT` which avoids the transition. This behavior is removed in rules_python 2.0.0 and thus upgrading beyond that threshold will break Windows tests.
>From 4b1c742be9ee225d809b844572a0e47edced1889 Mon Sep 17 00:00:00 2001
From: UebelAndre <github at uebelandre.com>
Date: Tue, 29 Sep 2026 06:45:58 -0700
Subject: [PATCH] [bazel] Keep lit tests on the platform-default runfiles mode;
bump rules_python to 1.9.0
---
utils/bazel/MODULE.bazel | 5 ++++-
utils/bazel/llvm-project-overlay/llvm/lit_test.bzl | 14 ++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/utils/bazel/MODULE.bazel b/utils/bazel/MODULE.bazel
index 785e897247b40b..4570b38d959dc1 100644
--- a/utils/bazel/MODULE.bazel
+++ b/utils/bazel/MODULE.bazel
@@ -13,7 +13,10 @@ bazel_dep(name = "apple_support", version = "2.6.1", repo_name = "build_bazel_ap
bazel_dep(name = "protobuf", version = "35.0", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_android", version = "0.7.2")
bazel_dep(name = "rules_cc", version = "0.2.25")
-bazel_dep(name = "rules_python", version = "1.8.4")
+
+# Keep below 2.0: from 2.0.0, py_binary on Windows requires symlink privileges
+# (https://github.com/bazel-contrib/rules_python/issues/3792).
+bazel_dep(name = "rules_python", version = "1.9.0")
bazel_dep(name = "rules_shell", version = "0.8.0")
# Latest pins: track upstream freely. No compatibility contract -- bump to
diff --git a/utils/bazel/llvm-project-overlay/llvm/lit_test.bzl b/utils/bazel/llvm-project-overlay/llvm/lit_test.bzl
index 2194c22ae148c5..359629c6619422 100644
--- a/utils/bazel/llvm-project-overlay/llvm/lit_test.bzl
+++ b/utils/bazel/llvm-project-overlay/llvm/lit_test.bzl
@@ -6,6 +6,19 @@
load("@bazel_skylib//lib:paths.bzl", "paths")
load("@rules_python//python:defs.bzl", _py_test = "py_test")
+# rules_python 1.9.0 made `--enable_runfiles=true` the default for every
+# py_binary/py_test on Windows, applied through a per-target transition. For
+# lit that is pure cost: the test still executes out of the self-extracting
+# zip, so the copied runfiles tree Bazel materializes beside it -- ~3400 files
+# and ~180 MB per test, most of it the CPython toolchain -- is never read, and
+# multiplied across the suite it exhausts the disk. The transition also gives
+# every lit test an `-ST-<hash>` output directory, and the 16 characters that
+# costs push the deepest MLIR tests past the 258-character cwd limit that
+# CreateProcessW enforces. `INHERIT` leaves the setting at whatever the
+# command line says, so the transition is a no-op and the tests run under the
+# platform default; on Linux and macOS nothing changes.
+_ENABLE_RUNFILES = Label("@rules_python//command_line_option:enable_runfiles")
+
# Python helper that resolves a path against the .cfg file's own location.
# Injected into rendered lit.site.cfg files so that dirname substitutions
# (which lit_expand_template renders as cfg-relative paths) resolve to absolute
@@ -210,6 +223,7 @@ def lit_test(
args = args + ["-v"] + ["$(rootpath %s)" % src for src in srcs],
data = data + srcs,
legacy_create_init = False,
+ config_settings = {_ENABLE_RUNFILES: "INHERIT"},
deps = deps + [Label("//llvm/utils/lit")],
**kwargs
)
More information about the llvm-commits
mailing list