runtime: compile test shaders through an ASCII-cwd glslang wrapper #2104

Closed
whoalin1 wants to merge 3 commits from upstream-pr/2104 into main
whoalin1 commented 2026-11-25 20:48:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T20:48:17Z.


Claimed in the coordination issue: https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7173272902 (BUILD-GLSLANG-NONASCII-RELATIVE-FIXTURE, from alexandersato0830's finding at https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7172499920).

What

Windows glslang (16.6.0 standalone) fast-fails with 0xC0000409 in a non-ASCII working directory, whatever its arguments say: the CRT resolves files through the narrow (ANSI codepage) current directory, and a character the codepage cannot represent crashes the runtime before main. A CMake build tree under a non-ASCII directory (a user name, a desktop folder) hits this for every shader the test build compiles.

This runs the validator through runtime/test/glslang_ascii_cwd.py, which keeps every byte glslang sees ASCII:

  • the working directory is the output directory's 8.3 short form (pure ASCII by construction on the system volume),
  • the output is written there under its relative name,
  • non-ASCII input files are hard-linked or copied in under plain ASCII names — the input's own 8.3 short form cannot be used because 8.3 truncates the extension to three letters (.comp → .com) and glslang classifies the shader stage from the extension.

Off Windows, without Python3, or in an already-ASCII tree the wrapper is a plain pass-through and nothing changes. When a path has no 8.3 short form (short names disabled on the volume) the validator runs exactly as it would without the wrapper — no regression — with a warning saying why.

Evidence (Windows 11, system codepage 1252, glslang 11:16.6.0 from VulkanSDK 1.4.363.0)

Failure reproduced on unmodified main — configure + cmake --build --target vk_null_descriptor_test in a build dir whose name holds CJK characters outside cp1252:

ninja: build stopped: subcommand failed.
Exit code 0xc0000409

the exact exit code alexandersato0830 reported (-1073740791). ninja's own log line shows the mechanism: cmd.exe /C "cd /D <unicode-build-dir> && glslangValidator ...".

Mechanism isolated: run directly, glslang crashes with 0xC0000409 whenever its cwd is non-ASCII — even with --stdin and no file arguments at all — while an ASCII cwd with Unicode absolute paths only fails to open the input (rc 1). The cwd is the deciding variable.

With this PR: the same configure + build in a CJK build directory succeeds; generated/cs_null_descriptors.spv is byte-identical to the ASCII-tree build (15036 bytes, valid SPIR-V magic). Wrapper-level checks: Unicode input + Unicode output + Unicode cwd, ASCII input + Unicode output/cwd (the reported scenario), and the all-ASCII pass-through all produce byte-identical output; staged input copies are cleaned up after the run.

Test plan

  • Control (unmodified main) fails in a CJK build dir with 0xC0000409
  • This branch builds vk_null_descriptor_test in a CJK build dir; SPIR-V byte-identical to ASCII build
  • ASCII-tree pass-through unchanged
  • CI

No game files involved; the shader is the synthetic GLSL test fixture. AI-assisted with Devin.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5498926914 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2104). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-25T20:48:17Z. --- Claimed in the coordination issue: https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7173272902 (BUILD-GLSLANG-NONASCII-RELATIVE-FIXTURE, from alexandersato0830's finding at https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7172499920). ## What Windows glslang (16.6.0 standalone) fast-fails with `0xC0000409` in a non-ASCII working directory, whatever its arguments say: the CRT resolves files through the narrow (ANSI codepage) current directory, and a character the codepage cannot represent crashes the runtime before `main`. A CMake build tree under a non-ASCII directory (a user name, a desktop folder) hits this for every shader the test build compiles. This runs the validator through `runtime/test/glslang_ascii_cwd.py`, which keeps every byte glslang sees ASCII: - the working directory is the output directory's **8.3 short form** (pure ASCII by construction on the system volume), - the output is written there under its relative name, - non-ASCII input files are hard-linked or copied in under plain ASCII names — the input's own 8.3 short form cannot be used because 8.3 truncates the extension to three letters (`.comp` → `.com`) and glslang classifies the shader stage from the extension. Off Windows, without Python3, or in an already-ASCII tree the wrapper is a plain pass-through and nothing changes. When a path has no 8.3 short form (short names disabled on the volume) the validator runs exactly as it would without the wrapper — no regression — with a warning saying why. ## Evidence (Windows 11, system codepage 1252, glslang 11:16.6.0 from VulkanSDK 1.4.363.0) **Failure reproduced on unmodified main** — configure + `cmake --build --target vk_null_descriptor_test` in a build dir whose name holds CJK characters outside cp1252: ``` ninja: build stopped: subcommand failed. Exit code 0xc0000409 ``` the exact exit code alexandersato0830 reported (-1073740791). ninja's own log line shows the mechanism: `cmd.exe /C "cd /D <unicode-build-dir> && glslangValidator ..."`. **Mechanism isolated**: run directly, glslang crashes with `0xC0000409` whenever its cwd is non-ASCII — even with `--stdin` and no file arguments at all — while an ASCII cwd with Unicode absolute paths only fails to open the input (rc 1). The cwd is the deciding variable. **With this PR**: the same configure + build in a CJK build directory succeeds; `generated/cs_null_descriptors.spv` is byte-identical to the ASCII-tree build (15036 bytes, valid SPIR-V magic). Wrapper-level checks: Unicode input + Unicode output + Unicode cwd, ASCII input + Unicode output/cwd (the reported scenario), and the all-ASCII pass-through all produce byte-identical output; staged input copies are cleaned up after the run. ## Test plan - [x] Control (unmodified main) fails in a CJK build dir with `0xC0000409` - [x] This branch builds `vk_null_descriptor_test` in a CJK build dir; SPIR-V byte-identical to ASCII build - [x] ASCII-tree pass-through unchanged - [ ] CI No game files involved; the shader is the synthetic GLSL test fixture. AI-assisted with Devin.
whoalin1 commented 2026-11-25 20:53:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T20:53:03Z.


Broader compile evidence in the same CJK build directory (system codepage 1252, glslang 16.6.0): built vk_overlapping_occlusion_test, vk_binary_occlusion_test and d3d12_descriptor_test on top of vk_null_descriptor_test — together these exercise the quoted-then-unquoted vulkan1.0 foreach sites, the vulkan1.2 site and the descriptor_test_shader function helper with its -D variant flags. 12 SPIR-V outputs across the four call-site patterns, all with valid magic, zero leftover staged inputs. Everything links and the two occlusion tests' unquoted list expansion works as intended. AI-assisted with Devin.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7174318361 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2104#issuecomment-7174318361). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-25T20:53:03Z. --- Broader compile evidence in the same CJK build directory (system codepage 1252, glslang 16.6.0): built `vk_overlapping_occlusion_test`, `vk_binary_occlusion_test` and `d3d12_descriptor_test` on top of `vk_null_descriptor_test` — together these exercise the quoted-then-unquoted `vulkan1.0` foreach sites, the `vulkan1.2` site and the `descriptor_test_shader` function helper with its `-D` variant flags. 12 SPIR-V outputs across the four call-site patterns, all with valid magic, zero leftover staged inputs. Everything links and the two occlusion tests' unquoted list expansion works as intended. AI-assisted with Devin.
MoonEyes commented 2026-11-28 03:01:09 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T03:01:09Z.


Hi @whoalin1, thanks for this pull request. It currently conflicts with main (conflicting file(s): runtime/CMakeLists.txt), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232740098 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2104#issuecomment-7232740098). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T03:01:09Z. --- Hi @whoalin1, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `runtime/CMakeLists.txt`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
zmasi commented 2026-11-28 23:37:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T23:37:00Z.


#2104 | head 20820abe09 (merged cleanly with main ba8b77b390) | live Windows 11 NTFS CJK working-directory + GetShortPathNameW 8.3 short-path wrapper probe + python -I tests/test_ctest_registration.py -v + python -I tests/test_ci_registration.py | red on main: runtime/test/glslang_ascii_cwd.py absent on main and runtime/CMakeLists.txt invoked "${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE}" directly without ASCII cwd / input staging | green on PR+main: live Windows 11 NTFS CJK + 8.3 short-path probe exited 0 (confirmed GetShortPathNameW resolved the CJK output folder to pure-ASCII 8.3 cwd, passed 100% ASCII args ['-V', '--target-env', 'vulkan1.0', '-o', 'overlapping_occlusion.frag.spv', '_leonida_in_0.comp'] preserving the .comp stage extension, wrote the .spv output, and unlinked _leonida_in_0.comp in finally), 7 ran, OK (test_ctest_registration.py), 18 ran, OK (test_ci_registration.py), and 3 ran, OK (test_text_write_line_endings.py) | Windows 11 (10.0.26200.9974), Python 3.12.10, NTFS (8.3 enabled) | AI-assisted: yes

Audited rebased head 20820abe09 (runtime/CMakeLists.txt and runtime/test/glslang_ascii_cwd.py) merged cleanly onto main (ba8b77b390) on Windows 11 — first independent verification report on this PR. Confirmed unquoted ${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE} list expansion in both add_custom_command(... VERBATIM) shader build rules (overlapping_occlusion and binary_occlusion), verified hard-link staging with copy fallback and guaranteed cleanup on Windows 11 NTFS, confirmed runtime/test/glslang_ascii_cwd.py is not flagged by tests/test_tool_stdout_encoding.py, and verified scripts/check_no_game_data.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7247549588 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2104#issuecomment-7247549588). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T23:37:00Z. --- #2104 | head 20820abe09d200b273f1e0cb1225b806cac8ca07 (merged cleanly with main ba8b77b390) | live Windows 11 NTFS CJK working-directory + `GetShortPathNameW` 8.3 short-path wrapper probe + `python -I tests/test_ctest_registration.py -v` + `python -I tests/test_ci_registration.py` | red on main: `runtime/test/glslang_ascii_cwd.py` absent on `main` and `runtime/CMakeLists.txt` invoked `"${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE}"` directly without ASCII `cwd` / input staging | green on PR+main: live Windows 11 NTFS CJK + 8.3 short-path probe exited `0` (confirmed `GetShortPathNameW` resolved the CJK output folder to pure-ASCII 8.3 `cwd`, passed 100% ASCII args `['-V', '--target-env', 'vulkan1.0', '-o', 'overlapping_occlusion.frag.spv', '_leonida_in_0.comp']` preserving the `.comp` stage extension, wrote the `.spv` output, and unlinked `_leonida_in_0.comp` in `finally`), `7 ran, OK` (`test_ctest_registration.py`), `18 ran, OK` (`test_ci_registration.py`), and `3 ran, OK` (`test_text_write_line_endings.py`) | Windows 11 (`10.0.26200.9974`), Python 3.12.10, NTFS (8.3 enabled) | AI-assisted: yes Audited rebased head `20820abe09` (`runtime/CMakeLists.txt` and `runtime/test/glslang_ascii_cwd.py`) merged cleanly onto `main` (`ba8b77b390`) on Windows 11 — first independent verification report on this PR. Confirmed unquoted `${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE}` list expansion in both `add_custom_command(... VERBATIM)` shader build rules (`overlapping_occlusion` and `binary_occlusion`), verified hard-link staging with copy fallback and guaranteed cleanup on Windows 11 NTFS, confirmed `runtime/test/glslang_ascii_cwd.py` is not flagged by `tests/test_tool_stdout_encoding.py`, and verified `scripts/check_no_game_data.py`.
whoalin1 commented 2026-11-30 22:30:18 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-30T22:30:18Z.


Rebased onto current main as a7fe77389 to refresh the stale CI baseline; the single-commit branch reapplied cleanly with no conflicts. Validation: CMake configure/generate passes, runtime/test/glslang_ascii_cwd.py compiles, and git diff --check is clean. Actual non-ASCII Windows execution remains covered by prior validator reports rather than locally rerun.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7293933719 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2104#issuecomment-7293933719). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-30T22:30:18Z. --- Rebased onto current `main` as `a7fe77389` to refresh the stale CI baseline; the single-commit branch reapplied cleanly with no conflicts. Validation: CMake configure/generate passes, `runtime/test/glslang_ascii_cwd.py` compiles, and `git diff --check` is clean. Actual non-ASCII Windows execution remains covered by prior validator reports rather than locally rerun.
whoalin1 commented 2026-11-30 22:38:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-30T22:38:42Z.


Fixed the Windows CI failure in 9c3e778c6: one gpu_profile_spin custom command still quoted ${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE}, collapsing the Python wrapper list into one semicolon-containing executable path. It now expands unquoted like the other glslang call sites. Validation: no quoted validator command remains, CMake configure/generate passes, and git diff --check is clean.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7294118012 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2104#issuecomment-7294118012). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-30T22:38:42Z. --- Fixed the Windows CI failure in `9c3e778c6`: one `gpu_profile_spin` custom command still quoted `${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE}`, collapsing the Python wrapper list into one semicolon-containing executable path. It now expands unquoted like the other glslang call sites. Validation: no quoted validator command remains, CMake configure/generate passes, and `git diff --check` is clean.
whoalin1 commented 2026-11-30 23:04:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-30T23:04:23Z.


The repaired head 9c3e778c6 is now mergeable with all visible checks green, including the Windows job that exposed the quoted-wrapper CMake failure.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7294674497 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2104#issuecomment-7294674497). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-30T23:04:23Z. --- The repaired head `9c3e778c6` is now mergeable with all visible checks green, including the Windows job that exposed the quoted-wrapper CMake failure.
aslan2142 commented 2026-12-01 10:47:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T10:47:22Z.

Review: CHANGES_REQUESTED


The 8.3 short-path ASCII cwd wrapper and unquoting of ${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE} in runtime/CMakeLists.txt look well-motivated, but requesting changes for a parallel-build race in runtime/test/glslang_ascii_cwd.py:140-168:

  • Almost every shader add_custom_command in runtime/CMakeLists.txt writes into the same output directory (${CMAKE_CURRENT_BINARY_DIR}), so work = out_dir is shared across all shader compilation jobs.
  • In runtime/test/glslang_ascii_cwd.py:140-155, each invocation stages non-ASCII input files as _leonida_in_0<ext>, _leonida_in_1<ext>, etc., deleting any existing file of the same name before linking/copying and removing it in finally (lines 164–168).
  • Under a parallel build (ninja -jN / msbuild /m) in a non-ASCII tree, two concurrent invocations compiling shaders with the same extension (e.g. .comp or .vert) will collide on _leonida_in_0<ext> in runtime/build, risking compiling the wrong input or failing with FileNotFoundError/PermissionError.

Scoping the staged filename per process (e.g. f"_leonida_in_{os.getpid()}_{index}{extension}" or creating a unique name atomically) avoids this parallel collision cleanly.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6129724612 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2104#pullrequestreview-6129724612). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T10:47:22Z. **Review:** CHANGES_REQUESTED --- The 8.3 short-path ASCII `cwd` wrapper and unquoting of `${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE}` in `runtime/CMakeLists.txt` look well-motivated, but requesting changes for a parallel-build race in `runtime/test/glslang_ascii_cwd.py:140-168`: - Almost every shader `add_custom_command` in `runtime/CMakeLists.txt` writes into the same output directory (`${CMAKE_CURRENT_BINARY_DIR}`), so `work = out_dir` is shared across all shader compilation jobs. - In `runtime/test/glslang_ascii_cwd.py:140-155`, each invocation stages non-ASCII input files as `_leonida_in_0<ext>`, `_leonida_in_1<ext>`, etc., deleting any existing file of the same name before linking/copying and removing it in `finally` (lines 164–168). - Under a parallel build (`ninja -jN` / `msbuild /m`) in a non-ASCII tree, two concurrent invocations compiling shaders with the same extension (e.g. `.comp` or `.vert`) will collide on `_leonida_in_0<ext>` in `runtime/build`, risking compiling the wrong input or failing with `FileNotFoundError`/`PermissionError`. Scoping the staged filename per process (e.g. `f"_leonida_in_{os.getpid()}_{index}{extension}"` or creating a unique name atomically) avoids this parallel collision cleanly. *(AI-assisted review.)*
whoalin1 commented 2026-12-01 11:21:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-12-01T11:21:50Z.


Implemented in 4b38e2f60: staged shader names now include the process ID before the index, so parallel invocations sharing the same output directory do not collide. Validation: python3 -m py_compile runtime/test/glslang_ascii_cwd.py passes; I did not rerun the Windows/MSVC build locally.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7309536346 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2104#issuecomment-7309536346). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-12-01T11:21:50Z. --- Implemented in `4b38e2f60`: staged shader names now include the process ID before the index, so parallel invocations sharing the same output directory do not collide. Validation: `python3 -m py_compile runtime/test/glslang_ascii_cwd.py` passes; I did not rerun the Windows/MSVC build locally.
aslan2142 commented 2026-12-01 16:42:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:42:07Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7318064085 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2104#issuecomment-7318064085). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:42:07Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2104
No description provided.