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

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

@⁠TimIdle on GitHub · 2026-11-24 14:24 UTC · original
TimIdle:test-cube-winpath → main · +5 −2 · 1 files · 1 commits · closed without merging

Claimed in the coordination issue as: TEST-CUBE-WINPATH (#14)

What and why

This carries on #419 by @⁠fiestorra, which its author closed unmerged at 12:19 UTC because they moved to another project. The commit is theirs (060c3c6, cherry-picked with -x, authorship kept). I rebased it onto main d0da7da and tested it again.

The bug is still on main. llvm_mc_cmd() in tests/semantic/test_image_cube_store_glc.py splits LLVM_MC with POSIX shlex.split, which drops the backslashes of a Windows path. So with LLVM_MC set the way scripts\build_llvm_mc.ps1 sets it, LlvmMcRoundTrip fails with FileNotFoundError before llvm-mc starts. The fix uses tools/mc_command.py, the helper the other tools already use. One file, 5 lines added and 2 removed.

Tested

On Windows 11 Home build 26300, Python 3.14.10 (MSYS2 UCRT64), llvm-mc 21.1.8 from scripts\build_llvm_mc.ps1:

  1. Before the fix (4562b98, which is main d0da7da plus one gpu-test-results file): run_semantic_tests.py gave 1 file failing, test_image_cube_store_glc, with FileNotFoundError: [WinError 2], LLVM_MC = C:\Users\...\.leonida\llvm-mc\llvm-mc.exe.
  2. This branch (28cd197), test_image_cube_store_glc.py alone:
    • LLVM_MC set to the backslash path: 9 tests OK.
    • LLVM_MC unset, llvm-mc on PATH: 9 tests OK.
    • Neither available: OK (skipped=1), so the skip rule is unchanged.
  3. This branch, the whole suite with LLVM_MC set to the backslash path: 465 files, 6108 tests, 0 files failed.
  4. python -I tests/test_mc_command.py: 29 tests OK (skipped=7). check_no_game_data.py on the changed file: clean.

This matches what @⁠quartz-heron-58 measured on #419 on another Windows 11 machine (Python 3.12.10).

GPUs tested: n/a (test-only change, CPU interpreter and llvm-mc only)

AI-assisted: yes (Claude Code: research, cherry-pick and test runs). The fix itself is fiestorra's.

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

**@⁠TimIdle** on GitHub · 2026-11-24 14:24 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/837) `TimIdle:test-cube-winpath` → `main` · +5 −2 · 1 files · 1 commits · closed without merging Claimed in the coordination issue as: TEST-CUBE-WINPATH (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why This carries on #419 by @⁠fiestorra, which its author closed unmerged at 12:19 UTC because they moved to another project. The commit is theirs (060c3c6, cherry-picked with -x, authorship kept). I rebased it onto main d0da7da and tested it again. The bug is still on main. `llvm_mc_cmd()` in `tests/semantic/test_image_cube_store_glc.py` splits `LLVM_MC` with POSIX `shlex.split`, which drops the backslashes of a Windows path. So with `LLVM_MC` set the way `scripts\build_llvm_mc.ps1` sets it, `LlvmMcRoundTrip` fails with `FileNotFoundError` before llvm-mc starts. The fix uses `tools/mc_command.py`, the helper the other tools already use. One file, 5 lines added and 2 removed. ### Tested On Windows 11 Home build 26300, Python 3.14.10 (MSYS2 UCRT64), llvm-mc 21.1.8 from scripts\build_llvm_mc.ps1: 1) Before the fix (4562b98, which is main d0da7da plus one gpu-test-results file): run_semantic_tests.py gave 1 file failing, test_image_cube_store_glc, with `FileNotFoundError: [WinError 2]`, LLVM_MC = `C:\Users\...\.leonida\llvm-mc\llvm-mc.exe`. 2) This branch (28cd197), test_image_cube_store_glc.py alone: - LLVM_MC set to the backslash path: 9 tests OK. - LLVM_MC unset, llvm-mc on PATH: 9 tests OK. - Neither available: OK (skipped=1), so the skip rule is unchanged. 3) This branch, the whole suite with LLVM_MC set to the backslash path: 465 files, 6108 tests, 0 files failed. 4) python -I tests/test_mc_command.py: 29 tests OK (skipped=7). check_no_game_data.py on the changed file: clean. This matches what @⁠quartz-heron-58 measured on #419 on another Windows 11 machine (Python 3.12.10). GPUs tested: n/a (test-only change, CPU interpreter and llvm-mc only) AI-assisted: yes (Claude Code: research, cherry-pick and test runs). The fix itself is fiestorra's. ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

(cherry picked from commit 060c3c6cf2)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:23:48 +00:00
github-bot closed this pull request 2026-11-26 09:23:48 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 14:25 UTC · original · approved these changes

Clean-Room Peer Review for PR #837 (TEST-CUBE-WINPATH: the cube semantic test cannot start llvm-mc when LLVM_MC is a Windows path)

Vital fix for Windows developer environments and CI runners:

  • Root Cause Resolution:
    • shlex.split(env) treats backslashes as escape characters under POSIX mode (default), which stripped \ from Windows paths (e.g., C:\llvm\bin\llvm-mc.exe -> C:llvmbinllvm-mc.exe), resulting in FileNotFoundError before invocation.
    • Using mc_command.mc_command(env) unifies the LLVM assembler invocation with the rest of the repository's toolchain ( ools/mc_command.py), safely preserving Windows drive letters, backslashes, and quoted spaces.
  • Impact on Semantic Conformance:
    • Unblocks local and CI execution of ests/semantic/test_image_cube_store_glc.py on Windows 11 without requiring bash wrappers or forward-slash path conversion.
  • Clean-room verification:
    • Standard library only, no external dependencies, LF line endings.

LGTM! Clear, concise, and necessary fix. Approved.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 14:25 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/837#pullrequestreview-6040992650) · **approved these changes** ### Clean-Room Peer Review for PR #837 (TEST-CUBE-WINPATH: the cube semantic test cannot start llvm-mc when LLVM_MC is a Windows path) Vital fix for Windows developer environments and CI runners: - **Root Cause Resolution**: - shlex.split(env) treats backslashes as escape characters under POSIX mode (default), which stripped \ from Windows paths (e.g., C:\llvm\bin\llvm-mc.exe -> C:llvmbinllvm-mc.exe), resulting in FileNotFoundError before invocation. - Using mc_command.mc_command(env) unifies the LLVM assembler invocation with the rest of the repository's toolchain ( ools/mc_command.py), safely preserving Windows drive letters, backslashes, and quoted spaces. - **Impact on Semantic Conformance**: - Unblocks local and CI execution of ests/semantic/test_image_cube_store_glc.py on Windows 11 without requiring bash wrappers or forward-slash path conversion. - **Clean-room verification**: - Standard library only, no external dependencies, LF line endings. LGTM! Clear, concise, and necessary fix. Approved.
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 14:27 UTC · original

Great catch on the Windows shlex.split backslash issue!

One quick note on standalone execution: when running this test standalone via python -I -m unittest tests/semantic/test_image_cube_store_glc.py, import mc_command raises ModuleNotFoundError because ools/ is not in sys.path (since -I excludes current working dir and sibling folders from sys.path).

Adding the standard sys.path boilerplate at the top:
python HERE = os.path.dirname(os.path.abspath(__file__)) TOOLS = os.path.join(os.path.dirname(os.path.dirname(HERE)), tools) for p in (HERE, TOOLS): if p not in sys.path: sys.path.insert(0, p)
will ensure mc_command and support resolve seamlessly in isolated environments.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 14:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/837#issuecomment-7134393617) Great catch on the Windows shlex.split backslash issue! One quick note on standalone execution: when running this test standalone via python -I -m unittest tests/semantic/test_image_cube_store_glc.py, import mc_command raises ModuleNotFoundError because ools/ is not in sys.path (since -I excludes current working dir and sibling folders from sys.path). Adding the standard sys.path boilerplate at the top: `python HERE = os.path.dirname(os.path.abspath(__file__)) TOOLS = os.path.join(os.path.dirname(os.path.dirname(HERE)), tools) for p in (HERE, TOOLS): if p not in sys.path: sys.path.insert(0, p) ` will ensure mc_command and support resolve seamlessly in isolated environments.
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 14:27 UTC · original · approved these changes

Clean-room verified (zero game data). Correct Windows path handling for LLVM_MC via mc_command.mc_command(env), avoiding backslash stripping by shlex.split. Tests pass under run_semantic_tests.py (9 tests, 8 passed, 1 skipped).

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 14:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/837#pullrequestreview-6041030865) · **approved these changes** Clean-room verified (zero game data). Correct Windows path handling for LLVM_MC via mc_command.mc_command(env), avoiding backslash stripping by shlex.split. Tests pass under run_semantic_tests.py (9 tests, 8 passed, 1 skipped).
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-24 15:56 UTC · original

Tested 28cd197e7 (applied onto main 23c459644) on Windows 11, Python 3.14.0. LLVM_MC is set to a native Windows path: C:\Users\...\miniforge3\envs\leonida\Library\bin\llvm-mc.exe (conda llvm-tools 23.1.5, AMDGPU target).

  • main: python -I scripts/run_semantic_tests.py tests/semantic -p test_image_cube_store_glc.py gives 1 file failed. LlvmMcRoundTrip errors with FileNotFoundError: [WinError 2] in subprocess.run, because shlex.split dropped the backslashes. A full run of tests/semantic on main on this machine gave 465 files, 6108 tests, and this was the only file that failed.- This PR: 9 tests, 0 failed. The llvm-mc round trip runs and passes.
  • This PR with LLVM_MC unset and no llvm-mc on PATH: OK (skipped=1), so the skip path still works.

No GPU, no game files. AI-assisted (Claude Code).

**@⁠adrianmjim** on GitHub · 2026-11-24 15:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/837#issuecomment-7136862375) Tested `28cd197e7` (applied onto `main` `23c459644`) on Windows 11, Python 3.14.0. `LLVM_MC` is set to a native Windows path: `C:\Users\...\miniforge3\envs\leonida\Library\bin\llvm-mc.exe` (conda llvm-tools 23.1.5, AMDGPU target). - `main`: `python -I scripts/run_semantic_tests.py tests/semantic -p test_image_cube_store_glc.py` gives 1 file failed. `LlvmMcRoundTrip` errors with `FileNotFoundError: [WinError 2]` in `subprocess.run`, because `shlex.split` dropped the backslashes. A full run of `tests/semantic` on `main` on this machine gave 465 files, 6108 tests, and this was the only file that failed.- This PR: 9 tests, 0 failed. The llvm-mc round trip runs and passes. - This PR with `LLVM_MC` unset and no `llvm-mc` on PATH: OK (skipped=1), so the skip path still works. No GPU, no game files. AI-assisted (Claude Code).
Author
Owner

@⁠TimIdle on GitHub · 2026-11-24 16:17 UTC · original

Thank you for the review. A standalone run fails at import support on main as well, before mc_command is reached. support.py puts tools/ on sys.path (line 16), so mc_command resolves once support imports. The missing HERE lines are the topic of #880, which already covers this file, so this PR stays on the LLVM_MC fix. @⁠adrianmjim thank you for the Windows run, including the case with LLVM_MC unset.

**@⁠TimIdle** on GitHub · 2026-11-24 16:17 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/837#issuecomment-7137412920) Thank you for the review. A standalone run fails at `import support` on `main` as well, before `mc_command` is reached. `support.py` puts `tools/` on `sys.path` (line 16), so `mc_command` resolves once `support` imports. The missing `HERE` lines are the topic of #880, which already covers this file, so this PR stays on the `LLVM_MC` fix. @⁠adrianmjim thank you for the Windows run, including the case with `LLVM_MC` unset.
Author
Owner

@⁠ccelestrix on GitHub · 2026-11-24 17:56 UTC · original

Independent check on a third Windows machine, at 28cd197 on top of main:

  • LLVM_MC=C:\Users\clstrx\.leonida\llvm-mc\llvm-mc.exe (the path scripts\build_llvm_mc.ps1 produces): tests/semantic/test_image_cube_store_glc.py runs 9 tests, OK. The same command on main ends in FileNotFoundError: [WinError 2] before llvm-mc starts.
  • LLVM_MC unset and no llvm-mc on PATH: 9 tests, 1 skipped, OK. The skip rule is unchanged.
  • Whole translator suite on this branch: 465 files, 6108 tests, 0 files failed in 213 s with 16 jobs (Windows 11, CPython 3.15.2).

The change is the repository's own helper (mc_command.mc_command(env)) instead of shlex.split, one file, and the fixture itself is untouched.

No game data, no GPU: n/a. Review run was AI-assisted.

**@⁠ccelestrix** on GitHub · 2026-11-24 17:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/837#issuecomment-7139937629) Independent check on a third Windows machine, at `28cd197` on top of `main`: - `LLVM_MC=C:\Users\clstrx\.leonida\llvm-mc\llvm-mc.exe` (the path `scripts\build_llvm_mc.ps1` produces): `tests/semantic/test_image_cube_store_glc.py` runs 9 tests, OK. The same command on `main` ends in `FileNotFoundError: [WinError 2]` before llvm-mc starts. - `LLVM_MC` unset and no `llvm-mc` on `PATH`: 9 tests, 1 skipped, OK. The skip rule is unchanged. - Whole translator suite on this branch: `465 files, 6108 tests, 0 files failed in 213 s with 16 jobs` (Windows 11, CPython 3.15.2). The change is the repository's own helper (`mc_command.mc_command(env)`) instead of `shlex.split`, one file, and the fixture itself is untouched. No game data, no GPU: n/a. Review run was AI-assisted.
Author
Owner

@⁠TimIdle on GitHub · 2026-11-24 18:05 UTC · original

Thank you for the check on a third machine, and for the run with LLVM_MC unset.

**@⁠TimIdle** on GitHub · 2026-11-24 18:05 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/837#issuecomment-7140151500) Thank you for the check on a third machine, and for the run with `LLVM_MC` unset.
Author
Owner

@⁠TimIdle on GitHub · 2026-11-25 11:19 UTC · original

Closing this one. main has the same fix since 273b3bdf: llvm_mc_cmd() in tests/semantic/test_image_cube_store_glc.py now uses mc_command.split_command, so this PR has nothing left to add.

Thanks @⁠fiestorra for the original fix in #419 and @⁠quartz-heron-58 for the Windows test.

AI-assisted: yes (Claude Code).

**@⁠TimIdle** on GitHub · 2026-11-25 11:19 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/837#issuecomment-7160890016) Closing this one. main has the same fix since 273b3bdf: `llvm_mc_cmd()` in `tests/semantic/test_image_cube_store_glc.py` now uses `mc_command.split_command`, so this PR has nothing left to add. Thanks @⁠fiestorra for the original fix in #419 and @⁠quartz-heron-58 for the Windows test. AI-assisted: yes (Claude Code).

Pull request closed

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