[llvm] [lit][bazel] Fall back to a default PATHEXT when the variable is unset (PR #217416)

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 19 11:03:15 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-testing-tools

Author: UebelAndre

<details>
<summary>Changes</summary>

When running tests on Windows with Bazel, we can enter a scenario where `PATHEXT` is stripped from the environment before python starts, resulting in binaries not being found. This change adds a common fallback in the event `PATHEXT` is ever undefined or set to an empty value.

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


1 Files Affected:

- (modified) llvm/utils/lit/lit/util.py (+2) 


``````````diff
diff --git a/llvm/utils/lit/lit/util.py b/llvm/utils/lit/lit/util.py
index 8ab109fe15d45..6bd435e4e74dc 100644
--- a/llvm/utils/lit/lit/util.py
+++ b/llvm/utils/lit/lit/util.py
@@ -131,6 +131,8 @@ def which(command, paths=None):
     # On Cygwin, 'PATHEXT' may exist but it should not be used.
     if os.pathsep == ";":
         pathext = os.environ.get("PATHEXT", "").split(";")
+        if not any(pathext):
+            pathext = [".COM", ".EXE", ".BAT", ".CMD"]
     else:
         pathext = [""]
 

``````````

</details>


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


More information about the llvm-commits mailing list