TEST-CUBE-WINPATH: the cube semantic test cannot start llvm-mc when LLVM_MC is a Windows path #419

Closed
leonida/mandy
fiestorra wants to merge 0 commits from carry/cube-winpath into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

fiestorra commented 2026-11-24 04:54:18 +00:00

Claimed in the coordination issue as: TEST-CUBE-WINPATH (claim comment).

What this changes

tests/semantic/test_image_cube_store_glc.py :52-57 has its own llvm_mc_cmd(), and it turns LLVM_MC into an argv with shlex.split(). shlex is POSIX word splitting: it treats a backslash as an escape, so a Windows path loses its separators. Set the variable the way docs/testing.md :16-21 tells Windows users to set it (scripts\build_llvm_mc.ps1 builds a native llvm-mc.exe and sets LLVM_MC for you) and the helper returns something like C:UsersIsegurav.leonida…llvm-mc.exe, subprocess.run raises FileNotFoundError inside LlvmMcRoundTrip, and the test errors instead of running. The @unittest.skipUnless(llvm_mc_cmd() is not None, …) guard cannot help: it only checks whether a value came back, not whether it names a program.

tools/mc_command.py is the helper every other tool in this tree already uses, and its split_command() docstring is "Split a command line without eating the backslashes of a Windows path (POSIX shlex would)". This file is the only one in the repository carrying a private copy. The change is to call mc_command.mc_command(env) there and keep the same rule for the skip case (llvm-mc on PATH, or skip when nothing is available). import support at :21 already puts tools/ on sys.path, which is how rdna2spirv is imported in the same file.

Evidence on ece4ba5b3

Head 060c3c6cf, one commit, tests/semantic/test_image_cube_store_glc.py only (+7 / −2). The tool used is the local llvm-mc.exe from scripts/build_llvm_mc.ps1 (LLVM 21.1.8), spirv-as/spirv-val from Vulkan SDK 1.4.363.0, CPython 3.13.14, Windows build 26300. No GPU is involved.

  • LLVM_MC=C:\Users\Isegurav\.leonida\llvm-mc\llvm-mc.exe, llvm-mc not on PATH — clean ece4ba5b3: Ran 9 tests in 0.550s / FAILED (errors=1). This branch: Ran 9 tests in 0.789s / OK.
  • llvm-mc on PATH, LLVM_MC unset — ece4ba5b3 OK (measured in the same session), this branch: Ran 9 tests in 0.774s / OK. Unchanged.
  • neither available — ece4ba5b3: Ran 9 tests in 0.554s / OK (skipped=1). This branch: Ran 9 tests in 0.552s / OK (skipped=1). The skip behaviour is what it was.
  • py -3.13 -I -m unittest discover -s tests -p "test_docs_*.py": Ran 47 tests in 23.944s / OK on this branch (and 47 / OK on clean ece4ba5b3 measured earlier in the same session).

This is the test my own old #9778 added, so the broken helper is mine and this is the follow-up, not a criticism of anyone else's work. Written with an AI assistant.

Claimed in the coordination issue as: `TEST-CUBE-WINPATH` ([claim comment](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7122401986)). ### What this changes `tests/semantic/test_image_cube_store_glc.py` :52-57 has its own `llvm_mc_cmd()`, and it turns `LLVM_MC` into an argv with `shlex.split()`. `shlex` is POSIX word splitting: it treats a backslash as an escape, so a Windows path loses its separators. Set the variable the way `docs/testing.md` :16-21 tells Windows users to set it (`scripts\build_llvm_mc.ps1` builds a native `llvm-mc.exe` and sets `LLVM_MC` for you) and the helper returns something like `C:UsersIsegurav.leonida…llvm-mc.exe`, `subprocess.run` raises `FileNotFoundError` inside `LlvmMcRoundTrip`, and the test errors instead of running. The `@unittest.skipUnless(llvm_mc_cmd() is not None, …)` guard cannot help: it only checks whether a value came back, not whether it names a program. `tools/mc_command.py` is the helper every other tool in this tree already uses, and its `split_command()` docstring is "Split a command line without eating the backslashes of a Windows path (POSIX shlex would)". This file is the only one in the repository carrying a private copy. The change is to call `mc_command.mc_command(env)` there and keep the same rule for the skip case (`llvm-mc` on `PATH`, or skip when nothing is available). `import support` at :21 already puts `tools/` on `sys.path`, which is how `rdna2spirv` is imported in the same file. ### Evidence on `ece4ba5b3` Head `060c3c6cf`, one commit, `tests/semantic/test_image_cube_store_glc.py` only (+7 / −2). The tool used is the local `llvm-mc.exe` from `scripts/build_llvm_mc.ps1` (LLVM 21.1.8), `spirv-as`/`spirv-val` from Vulkan SDK 1.4.363.0, CPython 3.13.14, Windows build 26300. No GPU is involved. * `LLVM_MC=C:\Users\Isegurav\.leonida\llvm-mc\llvm-mc.exe`, `llvm-mc` not on `PATH` — clean `ece4ba5b3`: `Ran 9 tests in 0.550s` / `FAILED (errors=1)`. This branch: `Ran 9 tests in 0.789s` / `OK`. * `llvm-mc` on `PATH`, `LLVM_MC` unset — `ece4ba5b3` `OK` (measured in the same session), this branch: `Ran 9 tests in 0.774s` / `OK`. Unchanged. * neither available — `ece4ba5b3`: `Ran 9 tests in 0.554s` / `OK (skipped=1)`. This branch: `Ran 9 tests in 0.552s` / `OK (skipped=1)`. The skip behaviour is what it was. * `py -3.13 -I -m unittest discover -s tests -p "test_docs_*.py"`: `Ran 47 tests in 23.944s / OK` on this branch (and 47 / OK on clean `ece4ba5b3` measured earlier in the same session). This is the test my own old #9778 added, so the broken helper is mine and this is the follow-up, not a criticism of anyone else's work. Written with an AI assistant.
demoz53 reviewed 2026-11-24 05:38:21 +00:00
demoz53 left a comment
No description provided.
Tested this branch on Windows 11 (Python 3.13, `llvm-mc` 21.1.8 from `scripts\build_llvm_mc.ps1`, Vulkan SDK 1.4.363): - **`LLVM_MC` = `C:\Users\<user>\.leonida\llvm-mc\llvm-mc.exe`:** the test passes. Without this PR it fails with `FileNotFoundError`, so the Windows-path fix works. - **`LLVM_MC` unset, an older `llvm-mc` first on PATH** (LLVM 14 from a MinGW toolchain, no AMDGPU target): it still **fails** with `unable to get target for 'amdgcn'` instead of being skipped. The `shutil.which("llvm-mc")` branch returns whatever `llvm-mc` comes first, and `skipUnless` only checks that one exists. A suggestion that covers both: probe the command once, the way `tests/semantic/test_lds_src2.py` (`_llvm_mc`) does, and return `None` when it can't encode for gfx1030: ```python def llvm_mc_cmd(): """llvm-mc's argv if it runs and has an AMDGPU target that knows gfx1030, else None.""" cmd = mc_command.mc_command() try: r = subprocess.run(cmd + ["-triple=amdgcn", "-mcpu=gfx1030", "-show-encoding"], input="s_endpgm\n", capture_output=True, text=True, timeout=60) except (OSError, subprocess.TimeoutExpired): return None return cmd if r.returncode == 0 and "encoding" in r.stdout else None ``` `mc_command.mc_command()` with no argument already reads `LLVM_MC` (and falls back to the default name), so `os.environ` and `shutil.which` aren't needed in the helper. With this version (and `import shlex` dropped), I get: Windows-path `LLVM_MC` passes, unset with the old `llvm-mc` on PATH skips, and the full translator suite is 465 files / 6,103 tests with 0 failures. The skip reason could then say `needs llvm-mc with the AMDGPU target (on PATH or LLVM_MC)`. (AI-assisted: Claude Code ran these tests.)
quartz-heron-58 commented 2026-11-24 08:29:00 +00:00

Tested 060c3c6c (cherry-picked onto main 1c93c869) on native Windows 11 Home (build 26300), Python 3.12.10, with LLVM_MC set to the native llvm-mc.exe that scripts\build_llvm_mc.ps1 builds (LLVM 21.1.8, a path with backslashes under %USERPROFILE%\.leonida): pass.

On main 1c93c869, python -I -m unittest discover -s tests/semantic -p test_image_cube_store_glc.py gives 9 tests with 1 error here: FileNotFoundError: [WinError 2] in LlvmMcRoundTrip.test_gfx1030_encode_decode_translate_and_validate. It is also the one file that fails in the full scripts/run_semantic_tests.py tests/semantic run on this machine. With this commit the file ends in OK. SPIRV-Tools v2026.4 on PATH. No game files.

AI-assisted (Claude Code ran the tests and wrote this comment).

Tested 060c3c6c (cherry-picked onto main 1c93c869) on native Windows 11 Home (build 26300), Python 3.12.10, with `LLVM_MC` set to the native `llvm-mc.exe` that `scripts\build_llvm_mc.ps1` builds (LLVM 21.1.8, a path with backslashes under `%USERPROFILE%\.leonida`): pass. On main 1c93c869, `python -I -m unittest discover -s tests/semantic -p test_image_cube_store_glc.py` gives 9 tests with 1 error here: `FileNotFoundError: [WinError 2]` in `LlvmMcRoundTrip.test_gfx1030_encode_decode_translate_and_validate`. It is also the one file that fails in the full `scripts/run_semantic_tests.py tests/semantic` run on this machine. With this commit the file ends in OK. SPIRV-Tools v2026.4 on PATH. No game files. AI-assisted (Claude Code ran the tests and wrote this comment).
fiestorra commented 2026-11-24 12:19:13 +00:00

Closing this. I am moving my work to a different project and will not continue here. I want to keep the test result on the record: quartz-heron-58 tested commit 060c3c6c on native Windows 11, which is evidence that this path handling behaved correctly outside the emulated path. That result stands on its own; I simply will not rebase or finish the branch myself. The branch will be deleted shortly.

Written with an AI assistant.

Closing this. I am moving my work to a different project and will not continue here. I want to keep the test result on the record: quartz-heron-58 tested commit 060c3c6c on native Windows 11, which is evidence that this path handling behaved correctly outside the emulated path. That result stands on its own; I simply will not rebase or finish the branch myself. The branch will be deleted shortly. Written with an AI assistant.
Sign in to join this conversation.
No description provided.