[llvm] [lit] Prevent "lld" from being substituted by LIT in llvm-driver tests (PR #191893)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 13 14:49:05 PDT 2026
https://github.com/zeroomega created https://github.com/llvm/llvm-project/pull/191893
We are seeing test failures in "passthrough-lld.test" as LIT substitutes the "ld.lld" string in the test file to the full path to the lld. However, the "-flavor" flag does not expect a full path. It just need a name of the linker so it fails. This patch adds an "no_substituions" option in the "use_lld" function in llvm/utils/lit/lit/llvm/config.py to allow individual tests to prevent tools from being substituted by LIT.
>From 685d6a52f00c50aa9aefba0f1abae7a10c674851 Mon Sep 17 00:00:00 2001
From: Haowei Wu <haowei at google.com>
Date: Mon, 13 Apr 2026 14:33:47 -0700
Subject: [PATCH] [lit] Prevent "lld" from being substituted by LIT in
llvm-driver tests
We are seeing test failures in "passthrough-lld.test" as LIT
substitutes the "ld.lld" string in the test file to the full
path to the lld. However, the "-flavor" flag does not expect
a full path. It just need a name of the linker so it fails.
This patch adds an "no_substituions" option in the "use_lld"
function in llvm/utils/lit/lit/llvm/config.py to allow
individual tests to prevent tools from being substituted by
LIT.
---
llvm/test/tools/llvm-driver/lit.local.cfg | 2 +-
llvm/utils/lit/lit/llvm/config.py | 14 +++++++++-----
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/llvm/test/tools/llvm-driver/lit.local.cfg b/llvm/test/tools/llvm-driver/lit.local.cfg
index 21771693b720e..0aa1a6e6fa6ac 100644
--- a/llvm/test/tools/llvm-driver/lit.local.cfg
+++ b/llvm/test/tools/llvm-driver/lit.local.cfg
@@ -1,4 +1,4 @@
from lit.llvm import llvm_config
-if llvm_config.use_lld(required=False):
+if llvm_config.use_lld(required=False, no_substitutions=["ld.lld"]):
config.available_features.add("lld")
diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py
index de70e80e60177..adb7b0a77a779 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -828,7 +828,7 @@ def prefer(this, to):
(" %clang-cl ", '''\"*** invalid substitution, use '%clang_cl'. ***\"''')
)
- def use_lld(self, additional_tool_dirs=[], required=True, use_installed=False):
+ def use_lld(self, additional_tool_dirs=[], required=True, use_installed=False, no_substitutions=()):
"""Configure the test suite to be able to invoke lld.
Sets up some environment variables important to lld, locates a
@@ -892,16 +892,20 @@ def use_lld(self, additional_tool_dirs=[], required=True, use_installed=False):
was_found = ld_lld and lld_link and ld64_lld and wasm_ld
tool_substitutions = []
if ld_lld:
- tool_substitutions.append(ToolSubst(r"ld\.lld", command=ld_lld))
+ if "ld.lld" not in no_substitutions:
+ tool_substitutions.append(ToolSubst(r"ld\.lld", command=ld_lld))
self.config.available_features.add("ld.lld")
if lld_link:
- tool_substitutions.append(ToolSubst("lld-link", command=lld_link))
+ if "lld-link" not in no_substitutions:
+ tool_substitutions.append(ToolSubst("lld-link", command=lld_link))
self.config.available_features.add("lld-link")
if ld64_lld:
- tool_substitutions.append(ToolSubst(r"ld64\.lld", command=ld64_lld))
+ if "ld64.lld" not in no_substitutions:
+ tool_substitutions.append(ToolSubst(r"ld64\.lld", command=ld64_lld))
self.config.available_features.add("ld64.lld")
if wasm_ld:
- tool_substitutions.append(ToolSubst("wasm-ld", command=wasm_ld))
+ if "wasm-ld" not in no_substitutions:
+ tool_substitutions.append(ToolSubst("wasm-ld", command=wasm_ld))
self.config.available_features.add("wasm-ld")
self.add_tool_substitutions(tool_substitutions)
More information about the llvm-commits
mailing list