[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 15:46:23 PDT 2026
https://github.com/zeroomega updated https://github.com/llvm/llvm-project/pull/191893
>From 3f2be0867502584dfd682ee6b08f11750f8cb850 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 modifies the lld matching regex in the use_lld
function in llvm/utils/lit/lit/llvm/config.py. It prevents
LIT from substitute any lld tool strings that are not
standalone.
---
llvm/utils/lit/lit/llvm/config.py | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py
index de70e80e60177..22bb15e449780 100644
--- a/llvm/utils/lit/lit/llvm/config.py
+++ b/llvm/utils/lit/lit/llvm/config.py
@@ -890,19 +890,24 @@ 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
+
+ lld_tools = [
+ ("ld.lld", ld_lld),
+ ("lld-link", lld_link),
+ ("ld64.lld", ld64_lld),
+ ("wasm-ld", wasm_ld),
+ ]
+
tool_substitutions = []
- if ld_lld:
- 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))
- self.config.available_features.add("lld-link")
- if ld64_lld:
- 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))
- self.config.available_features.add("wasm-ld")
+ for name, path in lld_tools:
+ if path:
+ escaped_name = name.replace(".", r"\.")
+ # Matches standalone name only, Avoid matching -flavor name, var=name
+ # cases.
+ regex = rf"(?<!-flavor\s)(?<!=)(?<![\.\-\^\/\\<])\b{escaped_name}\b(?![\.\-])"
+ tool_substitutions.append(ToolSubst(regex, command=path, verbatim=True))
+ self.config.available_features.add(name)
+
self.add_tool_substitutions(tool_substitutions)
return was_found
More information about the llvm-commits
mailing list