[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:44 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-testing-tools

Author: Haowei (zeroomega)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/191893.diff


2 Files Affected:

- (modified) llvm/test/tools/llvm-driver/lit.local.cfg (+1-1) 
- (modified) llvm/utils/lit/lit/llvm/config.py (+9-5) 


``````````diff
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)
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/191893


More information about the llvm-commits mailing list