summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Smiley <keithbsmiley@gmail.com>2024-03-28 19:07:22 -0700
committerGitHub <noreply@github.com>2024-03-28 19:07:22 -0700
commit89bae852dddeb2b66a1843dbe5eea21184e54814 (patch)
tree82db172ee729f2c4aea2fc0b565d509b078693a5
parent39e813746730a83e49b7efc457ff7efc74925c74 (diff)
[bazel] Fix lit tests with python 3.11+ (#87022)
In python3.11 there is a new environment variable PYTHONSAFEPATH which stops python from setting the current directory as the first entry in sys.path. Bazel started setting this to ensure that python targets don't accidentally access things that aren't in their dependency tree. This resulted in lit tests breaking because sys.path didn't include the directory to the lit source files. This is fixed by adding the lit binary to the dependency tree and propagating the import path from it. Fixes https://github.com/llvm/llvm-project/issues/75963
-rw-r--r--utils/bazel/llvm-project-overlay/llvm/BUILD.bazel1
-rw-r--r--utils/bazel/llvm-project-overlay/llvm/lit_test.bzl1
2 files changed, 2 insertions, 0 deletions
diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
index 3c3e17bfec66..15e477351fe3 100644
--- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -4927,6 +4927,7 @@ py_binary(
name = "lit",
testonly = True,
srcs = ["utils/lit/lit.py"] + glob(["utils/lit/lit/**/*.py"]),
+ imports = ["utils/lit"],
)
py_binary(
diff --git a/utils/bazel/llvm-project-overlay/llvm/lit_test.bzl b/utils/bazel/llvm-project-overlay/llvm/lit_test.bzl
index ce2a0a00c553..f754a9fc7d5e 100644
--- a/utils/bazel/llvm-project-overlay/llvm/lit_test.bzl
+++ b/utils/bazel/llvm-project-overlay/llvm/lit_test.bzl
@@ -35,6 +35,7 @@ def lit_test(
args = args + ["-v"] + ["$(execpath %s)" % src for src in srcs],
data = data + srcs,
legacy_create_init = False,
+ deps = [Label("//llvm:lit")],
**kwargs
)