diff options
| author | Urban225 <Urban225@users.noreply.github.com> | 2026-11-22 08:44:37 +0100 |
|---|---|---|
| committer | Urban225 <Urban225@users.noreply.github.com> | 2026-11-22 08:44:37 +0100 |
| commit | 49db06af8ab4ebf028dba948814536be66a3a5cf (patch) | |
| tree | 7c048fda35bf1d7bb993662d719d8221d797fd28 /tools/mc_command.py | |
| parent | c63773d51235d72250d48699f29830ac9ddafd60 (diff) | |
mc_command: an LLVM_MC path with spaces and no .exe stays one executable
On Windows, LLVM_MC=C:\Program Files\LLVM\bin\llvm-mc is no file under that
exact name, so split_command cut it at the space and every GPU tool tried to
run C:\Program. The same path without spaces worked, because Windows appends
.exe. A value with a directory part that shutil.which resolves is now kept
whole. Command lines and bare names are handled as before.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RcPmkK8w6mToPwmoiLYPZt
Diffstat (limited to 'tools/mc_command.py')
| -rw-r--r-- | tools/mc_command.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/mc_command.py b/tools/mc_command.py index 77f19b4c0..9c1f14946 100644 --- a/tools/mc_command.py +++ b/tools/mc_command.py | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | """Resolve LLVM_MC to an argv list. | 1 | """Resolve LLVM_MC to an argv list. |
| 2 | 2 | ||
| 3 | LLVM_MC may be one executable (a path, spaces and all) or a whole command line. Windows needs the command-line | 3 | LLVM_MC may be one executable (a path, spaces and all, with or without its .exe) or a whole command line. Windows |
| 4 | form when llvm-mc runs inside WSL, because the official Windows LLVM build has no AMDGPU target: | 4 | needs the command-line form when llvm-mc runs inside WSL, because the official Windows LLVM build has no AMDGPU |
| 5 | target: | ||
| 5 | 6 | ||
| 6 | set LLVM_MC=wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc | 7 | set LLVM_MC=wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc |
| 7 | """ | 8 | """ |
| @@ -9,6 +10,7 @@ from __future__ import annotations | |||
| 9 | 10 | ||
| 10 | import os | 11 | import os |
| 11 | import shlex | 12 | import shlex |
| 13 | import shutil | ||
| 12 | 14 | ||
| 13 | 15 | ||
| 14 | def split_command(raw: str) -> list: | 16 | def split_command(raw: str) -> list: |
| @@ -18,6 +20,10 @@ def split_command(raw: str) -> list: | |||
| 18 | return [] | 20 | return [] |
| 19 | if os.path.isfile(raw): | 21 | if os.path.isfile(raw): |
| 20 | return [raw] # a plain path, spaces and all | 22 | return [raw] # a plain path, spaces and all |
| 23 | if ("/" in raw or "\\" in raw) and shutil.which(raw): | ||
| 24 | # A path whose extension is left out (C:\Program Files\LLVM\bin\llvm-mc): Windows finds llvm-mc.exe | ||
| 25 | # for it, but it is no file under that exact name, so it used to be split at its spaces. | ||
| 26 | return [raw] | ||
| 21 | try: | 27 | try: |
| 22 | if os.name != "nt": | 28 | if os.name != "nt": |
| 23 | parts = shlex.split(raw) | 29 | parts = shlex.split(raw) |