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

Closed
github-bot wants to merge 1 commit from gh-pr/419/head into gh-pr/419/base
Owner

@⁠fiestorra on GitHub · 2026-11-24 04:54 UTC · original
fiestorra:carry/cube-winpath → main · +5 −2 · 1 files · 1 commits · closed without merging

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.

**@⁠fiestorra** on GitHub · 2026-11-24 04:54 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/419) `fiestorra:carry/cube-winpath` → `main` · +5 −2 · 1 files · 1 commits · closed without merging Claimed in the coordination issue as: `TEST-CUBE-WINPATH` ([claim comment](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14)). ### 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.
LlvmMcRoundTrip is skipped when no llvm-mc can be found, and runs when one can. It broke for the one case in between: LLVM_MC set to a Windows path. llvm_mc_cmd() passed that value through shlex.split, which is POSIX word splitting and drops the backslashes, so the argv became C:UsersIsegurav...llvm-mc.exe and the subprocess call failed with FileNotFoundError instead of the test running; the skipUnless never got a chance to skip it. docs/testing.md tells Windows users to set LLVM_MC (scripts\build_llvm_mc.ps1 sets it), so the documented setup is what triggers it. tools/mc_command.py already exists for exactly this ('Split a command line without eating the backslashes of a Windows path (POSIX shlex would)') and this file is the only one in the tree carrying its own copy. Measured on ece4ba5b3 with LLVM_MC=C:\Users\Isegurav\.leonida\llvm-mc\llvm-mc.exe: main 9 tests / 1 error, this branch 9 tests / OK; with llvm-mc on PATH and LLVM_MC unset both are OK, and with neither available both report OK (skipped=1), so the skip rule is unchanged. tests/test_docs_*.py: 47 tests OK on both sides.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:59:08 +00:00
github-bot closed this pull request 2026-11-26 08:59:08 +00:00
Author
Owner

@⁠demoz53 on GitHub · 2026-11-24 05:38 UTC · original · reviewed

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:

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.)

**@⁠demoz53** on GitHub · 2026-11-24 05:38 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/419#pullrequestreview-6034237798) · **reviewed** 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.)
Author
Owner

@⁠quartz-heron-58 on GitHub · 2026-11-24 08:29 UTC · original

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).

**@⁠quartz-heron-58** on GitHub · 2026-11-24 08:29 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/419#issuecomment-7126188719) 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).
Author
Owner

@⁠fiestorra on GitHub · 2026-11-24 12:19 UTC · original

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.

**@⁠fiestorra** on GitHub · 2026-11-24 12:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/419#issuecomment-7131272608) 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.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.