Skip to content

Commit f5c1c6f

Browse files
committed
Fixed Tools/jit/_llvm.py
1 parent 5477f5b commit f5c1c6f

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

Tools/jit/_llvm.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ async def wrapper(
3838
_CORES = asyncio.BoundedSemaphore(os.cpu_count() or 1)
3939

4040

41+
def _candidate_names(tool: str) -> list[str]:
42+
candidates = [tool]
43+
if os.name == "nt":
44+
candidates.append(f"{tool}.exe")
45+
return candidates
46+
47+
4148
async def _run(tool: str, args: typing.Iterable[str], echo: bool = False) -> str | None:
4249
command = [tool, *args]
4350
async with _CORES:
@@ -70,24 +77,26 @@ async def _get_brew_llvm_prefix(*, echo: bool = False) -> str | None:
7077
@_async_cache
7178
async def _find_tool(tool: str, *, echo: bool = False) -> str | None:
7279
# Unversioned executables:
73-
path = tool
74-
if await _check_tool_version(path, echo=echo):
75-
return path
80+
for path in _candidate_names(tool):
81+
if await _check_tool_version(path, echo=echo):
82+
return path
7683
# Versioned executables:
77-
path = f"{tool}-{_LLVM_VERSION}"
78-
if await _check_tool_version(path, echo=echo):
79-
return path
84+
for path in _candidate_names(f"{tool}-{_LLVM_VERSION}"):
85+
if await _check_tool_version(path, echo=echo):
86+
return path
8087
# PCbuild externals:
8188
externals = os.environ.get("EXTERNALS_DIR", _targets.EXTERNALS)
82-
path = os.path.join(externals, _EXTERNALS_LLVM_TAG, "bin", tool)
83-
if await _check_tool_version(path, echo=echo):
84-
return path
89+
for name in _candidate_names(tool):
90+
path = os.path.join(externals, _EXTERNALS_LLVM_TAG, "bin", name)
91+
if await _check_tool_version(path, echo=echo):
92+
return path
8593
# Homebrew-installed executables:
8694
prefix = await _get_brew_llvm_prefix(echo=echo)
8795
if prefix is not None:
88-
path = os.path.join(prefix, "bin", tool)
89-
if await _check_tool_version(path, echo=echo):
90-
return path
96+
for name in _candidate_names(tool):
97+
path = os.path.join(prefix, "bin", name)
98+
if await _check_tool_version(path, echo=echo):
99+
return path
91100
# Nothing found:
92101
return None
93102

0 commit comments

Comments
 (0)