upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/tools/mc_command.py
diff options
context:
space:
mode:
authorFelix Croasdale <205819305+etcetera-yt@users.noreply.github.com>2026-11-22 03:02:20 -0600
committerFelix Croasdale <205819305+etcetera-yt@users.noreply.github.com>2026-11-22 03:02:20 -0600
commite63bf6bdefa9c41340a3c1f7fde428ee676b1d8e (patch)
tree51f9b8092b65373590a7e0b8fb9ab231fb3e2726 /tools/mc_command.py
parent426023a585b47ba04509d5f3e5e52d6ae40e1109 (diff)
mc_command.run: a missing llvm-mc is one line, not a FileNotFoundError traceback
Without llvm-mc, run_gpu_tests.py, valu_fuzz.py, lds_fuzz.py, image_fuzz.py, crosslane_fuzz.py and runtime/test/shaders/build.py ended in 'FileNotFoundError: [WinError 2]' from subprocess.run: the first step of TEST-71 on a Windows machine without one. Only shader_disasm.py said what was missing. mc_command.run() starts an llvm-mc command and turns a command that can't be started into shader_disasm.py's message (set LLVM_MC or --llvm-mc, build_llvm_mc.ps1, the WSL form); the six llvm-mc call sites use it. tests/test_mc_command.py covers run() and each tool with a nonexistent LLVM_MC. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tools/mc_command.py')
-rw-r--r--tools/mc_command.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/mc_command.py b/tools/mc_command.py
index 9c1f14946..b21f5a4ce 100644
--- a/tools/mc_command.py
+++ b/tools/mc_command.py
@@ -5,12 +5,15 @@ needs the command-line form when llvm-mc runs inside WSL, because the official W
5target: 5target:
6 6
7 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
8
9run() starts such a command and turns a missing llvm-mc into one line instead of a FileNotFoundError traceback.
8""" 10"""
9from __future__ import annotations 11from __future__ import annotations
10 12
11import os 13import os
12import shlex 14import shlex
13import shutil 15import shutil
16import subprocess
14 17
15 18
16def split_command(raw: str) -> list: 19def split_command(raw: str) -> list:
@@ -41,3 +44,18 @@ def mc_command(raw: str | None = None) -> list:
41 if raw is None: 44 if raw is None:
42 raw = os.environ.get("LLVM_MC", "llvm-mc") 45 raw = os.environ.get("LLVM_MC", "llvm-mc")
43 return split_command(raw) or ["llvm-mc"] 46 return split_command(raw) or ["llvm-mc"]
47
48
49def not_found(exe: str, error: OSError) -> str:
50 """The message for an llvm-mc that can't be started (shader_disasm.py's wording)."""
51 return (f"'{exe}' could not be started: {error}. Put llvm-mc on PATH or set LLVM_MC (or --llvm-mc) to it\n"
52 f"(on Windows, scripts\\build_llvm_mc.ps1 builds one and sets it), e.g.\n"
53 f" LLVM_MC=wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc")
54
55
56def run(cmd: list, **kwargs) -> subprocess.CompletedProcess:
57 """subprocess.run for an llvm-mc command line; one that can't be started ends the tool with not_found()."""
58 try:
59 return subprocess.run(cmd, **kwargs)
60 except OSError as e:
61 raise SystemExit(not_found(cmd[0], e)) from None