diff --git a/scripts/bench_wave64.py b/scripts/bench_wave64.py index 57253cb574..3a566ebfdf 100644 --- a/scripts/bench_wave64.py +++ b/scripts/bench_wave64.py @@ -97,7 +97,8 @@ def main(): ap = argparse.ArgumentParser() ap.add_argument("--build", default=os.path.join(ROOT, "runtime", "build"), help="CMake build directory or a configuration directory such as RelWithDebInfo") - ap.add_argument("--llvm-mc", default=os.environ.get("LLVM_MC", "llvm-mc")) + # Empty means unset to build.py: mc_command() then finds llvm-mc on PATH or a versioned llvm-mc-. + ap.add_argument("--llvm-mc", default=os.environ.get("LLVM_MC", "")) # Vulkan guarantees support for at least 65,535 groups along X in one dispatch. ap.add_argument("--groups", type=positive_int, default=65535) ap.add_argument("--reps", type=positive_int, default=30) diff --git a/scripts/run_address_guard_gpu_test.py b/scripts/run_address_guard_gpu_test.py index f7aa533664..c61b347043 100644 --- a/scripts/run_address_guard_gpu_test.py +++ b/scripts/run_address_guard_gpu_test.py @@ -68,15 +68,19 @@ def find_tool(build, name): def main(argv=None): ap = argparse.ArgumentParser(description=__doc__.split("\n\n")[0]) ap.add_argument("--build", default=os.path.join(ROOT, "runtime", "build"), help="folder with vk_compute_test") - ap.add_argument("--llvm-mc", default=os.environ.get("LLVM_MC", "llvm-mc")) + # No literal default: unset, mc_command() reads LLVM_MC and then finds llvm-mc on PATH or a versioned + # Debian/Ubuntu install (llvm-mc-21, /usr/lib/llvm-21/bin/llvm-mc), as run_gpu_tests.py does. + ap.add_argument("--llvm-mc", default=None) ap.add_argument("--work", default=None, help="keep the intermediate files here") a = ap.parse_args(argv) vk_compute = find_tool(a.build, "vk_compute_test") if not vk_compute: print(f"SKIP: no vk_compute_test under {a.build}") return 77 - if not shutil.which(a.llvm_mc.split()[0]): - print(f"SKIP: {a.llvm_mc} not found") + import mc_command + mc = mc_command.mc_command(a.llvm_mc) + if not shutil.which(mc[0]): + print(f"SKIP: {' '.join(mc)} not found") return 77 sys.path.insert(0, os.path.join(ROOT, "runtime", "test", "shaders")) sys.path.insert(0, os.path.join(ROOT, "scripts")) diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py index 60e9687830..4d7a601d4f 100644 --- a/scripts/run_gpu_tests.py +++ b/scripts/run_gpu_tests.py @@ -102,7 +102,7 @@ def make_ms_psv0(threads_x: int, maxv: int, maxp: int, topology: int = 2, group_ TEXT_ONLY_MARK = "; run_gpu_tests: text only, llvm-mc has no gfx1013 encoding for an instruction here" -def assemble_to_s(llvm_mc: str, asm_path: str, s_path: str, name: str) -> None: +def assemble_to_s(llvm_mc: str | None, asm_path: str, s_path: str, name: str) -> None: """Assemble raw RDNA2 .asm with llvm-mc -show-encoding into .s format for rdna2spirv.py.""" with open(asm_path, encoding="utf-8") as source: raw = source.read() @@ -762,8 +762,11 @@ def fits(p: str) -> bool: def main() -> int: ap = argparse.ArgumentParser() - ap.add_argument("--llvm-mc", default=os.environ.get("LLVM_MC", "llvm-mc"), - help="llvm-mc path, or a whole command such as 'wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc'") + # No literal default: unset, mc_command() reads LLVM_MC and then finds llvm-mc on PATH or a versioned + # Debian/Ubuntu install (llvm-mc-21, /usr/lib/llvm-21/bin/llvm-mc), as the not-found message promises. + ap.add_argument("--llvm-mc", default=None, + help="llvm-mc path, or a whole command such as 'wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc' " + "(default: LLVM_MC, then llvm-mc on PATH, then the newest llvm-mc-)") ap.add_argument("--build", default=os.path.join(ROOT, "runtime", "build"), help="CMake build folder; with the Visual Studio generator the RelWithDebInfo/Release/... " "subfolder that has the test programs is found by itself") diff --git a/tests/test_mc_command.py b/tests/test_mc_command.py index d3baf56826..ff9209f89d 100644 --- a/tests/test_mc_command.py +++ b/tests/test_mc_command.py @@ -202,6 +202,21 @@ def test_the_message_names_the_distribution_package_off_windows(self): self.assertNotIn("build_llvm_mc.ps1", message) + def test_no_tool_pins_the_plain_name_as_its_default(self): + # run_gpu_tests.py once defaulted --llvm-mc to os.environ.get("LLVM_MC", "llvm-mc"), so with only + # Ubuntu's llvm-21 installed it never reached versioned_llvm_mc() and failed with the very message that + # says /usr/lib/llvm-21/bin/llvm-mc is found without further setup. + import re + pinned = re.compile(r"""get\(\s*["']LLVM_MC["']\s*,\s*["']llvm-mc["']\s*\)""") + found = [] + for folder in ("scripts", "tools", os.path.join("runtime", "test", "shaders")): + for name in sorted(os.listdir(os.path.join(ROOT, folder))): + if name.endswith(".py"): + with open(os.path.join(ROOT, folder, name), encoding="utf-8") as f: + if pinned.search(f.read()): + found.append(f"{folder}/{name}") + self.assertEqual(found, [], "use mc_command.mc_command() (or an empty LLVM_MC) instead of a literal llvm-mc") + class MissingLlvmMcTest(unittest.TestCase): """An llvm-mc that can't be started ends each tool with one line, not a FileNotFoundError traceback."""