From 66a410edf0c4d387ef5414efc10e684c5687e45b Mon Sep 17 00:00:00 2001 From: Mokbul Miah <12134052+mokkymiah@users.noreply.github.com> Date: Sat, 21 Nov 2026 20:56:01 +0000 Subject: Accept LLVM_MC as a whole command in the tests and GPU tools LLVM_MC may be one executable or a command line such as the WSL llvm-mc documented for Windows. shader_disasm.py already split it, but the tests, runtime/test/shaders/build.py and scripts/run_gpu_tests.py treated it as a single executable, so the documented setup skipped translator tests, and build.py passed a Windows path to WSL. Share the splitter in tools/mc_command.py and feed assembly on stdin. --- tools/mc_command.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tools/mc_command.py (limited to 'tools/mc_command.py') diff --git a/tools/mc_command.py b/tools/mc_command.py new file mode 100644 index 000000000..9f76e03b4 --- /dev/null +++ b/tools/mc_command.py @@ -0,0 +1,29 @@ +"""Resolve LLVM_MC to an argv list. + +LLVM_MC may be one executable (a path, spaces and all) or a whole command line. Windows needs the command-line +form when llvm-mc runs inside WSL, because the official Windows LLVM build has no AMDGPU target: + + set LLVM_MC=wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc +""" +import os +import shlex + + +def split_command(raw: str) -> list: + """Split a command line without eating the backslashes of a Windows path (POSIX shlex would).""" + raw = raw.strip() + if not raw: + return [] + if os.path.isfile(raw): + return [raw] # a plain path, spaces and all + if os.name != "nt": + return shlex.split(raw) + parts = shlex.split(raw, posix=False) + return [p[1:-1] if len(p) > 1 and p[0] == p[-1] == '"' else p for p in parts] + + +def mc_command(raw: str | None = None) -> list: + """LLVM_MC is a path, or a command line: 'wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc'.""" + if raw is None: + raw = os.environ.get("LLVM_MC", "llvm-mc") + return split_command(raw) or ["llvm-mc"] -- cgit v1.2.3