runtime: generate shared BCPack tables once in parallel builds #1628

Closed
sodove wants to merge 1 commit from upstream-pr/1628 into main
sodove commented 2026-11-25 06:18:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-25T06:18:00Z.


Claimed in the coordination issue as: RT-BCPACK-TABLES-BUILD-RACE.

What and why

On a clean parallel Visual Studio build, both the history trainer and the runtime decoder ran the generator for bcpack_tables.inc. One observed build failed with Python PermissionError and MSBuild MSB8066. A clean build of 42537e7b6 ran it twice even when the build succeeded.

Give the existing output rule a single CMake target and make both consumers depend on it. Their C++ compile steps can still run in parallel once the include exists. The generator, its inputs and the generated bytes are unchanged.

Tested

Native Windows 11 x64, MSVC, RelWithDebInfo. All inputs were synthetic or from the repository.

Check Result
Visual Studio 2022, clean parallel build One project owns the generator rule (two on base), one generator invocation
Rebuild with no changes, then rebuild after removing the generated include Zero invocations, then one. Both consumers recompiled and the regenerated include matched the clean build byte for byte.
Ninja, touch a generator input in a scratch source tree One invocation and both consumers recompiled. The next build did no work.
History trainer on one valid and one malformed synthetic stream Both builds accepted one, rejected one and produced identical output.
CPU-only runtime CTest 144 passed, including dstorage. Seven package-dependent tests skipped and two SDL tests were disabled.
Translator semantic suite 487 files, 6,279 tests, zero failing files.
BCPack table unit tests 55 passed.

GPUs tested: n/a (host build and CPU tests).

AI-assisted: yes (OpenAI Codex).

Checklist

  • Based on current main.
  • One topic.
  • No game data, keys or decryption.
  • Translator contract update is inapplicable to this build change.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5486250521 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1628). Originally posted by [sodove](https://github.com/sodove) on 2026-11-25T06:18:00Z. --- Claimed in the coordination issue as: [RT-BCPACK-TABLES-BUILD-RACE](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7154531555). ### What and why On a clean parallel Visual Studio build, both the history trainer and the runtime decoder ran the generator for `bcpack_tables.inc`. One observed build failed with Python `PermissionError` and MSBuild `MSB8066`. A clean build of `42537e7b6` ran it twice even when the build succeeded. Give the existing output rule a single CMake target and make both consumers depend on it. Their C++ compile steps can still run in parallel once the include exists. The generator, its inputs and the generated bytes are unchanged. ### Tested Native Windows 11 x64, MSVC, RelWithDebInfo. All inputs were synthetic or from the repository. | Check | Result | | --- | --- | | Visual Studio 2022, clean parallel build | One project owns the generator rule (two on base), one generator invocation | | Rebuild with no changes, then rebuild after removing the generated include | Zero invocations, then one. Both consumers recompiled and the regenerated include matched the clean build byte for byte. | | Ninja, touch a generator input in a scratch source tree | One invocation and both consumers recompiled. The next build did no work. | | History trainer on one valid and one malformed synthetic stream | Both builds accepted one, rejected one and produced identical output. | | CPU-only runtime CTest | 144 passed, including `dstorage`. Seven package-dependent tests skipped and two SDL tests were disabled. | | Translator semantic suite | 487 files, 6,279 tests, zero failing files. | | BCPack table unit tests | 55 passed. | GPUs tested: n/a (host build and CPU tests). AI-assisted: yes (OpenAI Codex). ### Checklist - [x] Based on current `main`. - [x] One topic. - [x] No game data, keys or decryption. - [x] Translator contract update is inapplicable to this build change.
whoalin1 commented 2026-11-25 10:35:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-25T10:35:14Z.


Independent verification (Windows): CMakeLists-only change replacing ${bcpack_tables} as a source with phony gta6rt_bcpack_tables target + add_dependencies — the canonical fix for the MSBuild double-generation race. Verified live under Ninja: build.ninja has exactly one CUSTOM_COMMAND edge for bcpack_tables.inc; clean build generates once before both consumers; touch tools/bcpack_tables.py + ninja -n plans exactly one generation then parallel compiles+links — incremental correctness preserved. Full compile blocked by a sandbox /Zi debug-records issue (reproduced with trivial t.cpp — environmental, base fails identically); author's VS2022 clean-parallel claim is consistent with the standard pattern. AI-assisted verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7159898497 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1628#issuecomment-7159898497). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-25T10:35:14Z. --- Independent verification (Windows): CMakeLists-only change replacing `${bcpack_tables}` as a *source* with phony `gta6rt_bcpack_tables` target + `add_dependencies` — the canonical fix for the MSBuild double-generation race. Verified live under Ninja: build.ninja has exactly one CUSTOM_COMMAND edge for bcpack_tables.inc; clean build generates once before both consumers; `touch tools/bcpack_tables.py` + `ninja -n` plans exactly one generation then parallel compiles+links — incremental correctness preserved. Full compile blocked by a sandbox `/Zi` debug-records issue (reproduced with trivial t.cpp — environmental, base fails identically); author's VS2022 clean-parallel claim is consistent with the standard pattern. AI-assisted verification.
zmasi commented 2026-11-29 00:36:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T00:36:33Z.


Windows 11 + CMake VS 2022 + MSBuild /m:4 Verification — PASS (3da3c7ffed)

Verified 3da3c7ffed merged onto origin/main (829530dbd0 and 48bae6cade, 0 conflicts, plus a 5-way combined merge alongside #1918, #1579, #2198, and #900) on native Windows 11 (10.0.26200.9974) with CMake (Visual Studio 17 2022, -A x64) and MSBuild 17.14.40 (/m:4).

Checks Run

  • Red (.vcxproj generation on origin/main):
    • Configured runtime/ with -G "Visual Studio 17 2022" -A x64 and inspected all generated .vcxproj files: confirmed origin/main emits duplicate gen_bcpack_runtime_tables.py CustomBuild rules into both bcpack_history_train.vcxproj and gta6rt_bcpack.vcxproj writing the same bcpack_tables.inc output file.
  • Green (.vcxproj generation + concurrent multi-target MSBuild /m:4 rebuild on #1628 + origin/main):
    • Inspected all generated .vcxproj files: confirmed only gta6rt_bcpack_tables.vcxproj contains the gen_bcpack_runtime_tables.py CustomBuild rule, while both bcpack_history_train.vcxproj and gta6rt_bcpack.vcxproj carry <ProjectReference> links to gta6rt_bcpack_tables.vcxproj (0 duplicate custom build rules).
    • Removed bcpack_tables.inc and executed a single concurrent multi-project rebuild MSBuild.exe gta6rt.sln /m:4 /t:bcpack_history_train:Rebuild;gta6rt_bcpack:Rebuild /p:Configuration=RelWithDebInfo: exited 0, invoked "Generating bcpack_tables.inc" exactly 1 time across the parallel build graph, and produced both bcpack_history_train.exe and gta6rt_bcpack.lib cleanly.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248230420 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1628#issuecomment-7248230420). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-29T00:36:33Z. --- ## Windows 11 + CMake VS 2022 + MSBuild `/m:4` Verification — PASS (`3da3c7ffed`) Verified `3da3c7ffed` merged onto `origin/main` (`829530dbd0` and `48bae6cade`, `0` conflicts, plus a 5-way combined merge alongside `#1918`, `#1579`, `#2198`, and `#900`) on native Windows 11 (`10.0.26200.9974`) with CMake (`Visual Studio 17 2022`, `-A x64`) and MSBuild `17.14.40` (`/m:4`). ### Checks Run - **Red (`.vcxproj` generation on `origin/main`)**: - Configured `runtime/` with `-G "Visual Studio 17 2022" -A x64` and inspected all generated `.vcxproj` files: confirmed `origin/main` emits duplicate `gen_bcpack_runtime_tables.py` `CustomBuild` rules into **both** `bcpack_history_train.vcxproj` and `gta6rt_bcpack.vcxproj` writing the same `bcpack_tables.inc` output file. - **Green (`.vcxproj` generation + concurrent multi-target MSBuild `/m:4` rebuild on `#1628 + origin/main`)**: - Inspected all generated `.vcxproj` files: confirmed **only** `gta6rt_bcpack_tables.vcxproj` contains the `gen_bcpack_runtime_tables.py` `CustomBuild` rule, while both `bcpack_history_train.vcxproj` and `gta6rt_bcpack.vcxproj` carry `<ProjectReference>` links to `gta6rt_bcpack_tables.vcxproj` (`0` duplicate custom build rules). - Removed `bcpack_tables.inc` and executed a single concurrent multi-project rebuild `MSBuild.exe gta6rt.sln /m:4 /t:bcpack_history_train:Rebuild;gta6rt_bcpack:Rebuild /p:Configuration=RelWithDebInfo`: exited `0`, invoked `"Generating bcpack_tables.inc"` exactly **`1`** time across the parallel build graph, and produced both `bcpack_history_train.exe` and `gta6rt_bcpack.lib` cleanly. AI-assisted.
TheGeogeo commented 2026-11-29 02:17:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T02:17:08Z.


Tested 3da3c7ffe merged (no commit) with main 53b77df14. GPUs tested: NVIDIA GeForce RTX 3080, driver 621.40, Windows 11 10.0.26300; MSVC 19.52 (Visual Studio 18), Ninja, RelWithDebInfo; Python 3.12.4. check_no_game_data.py is clean.

  • No test, and no visible effect with Ninja: the change matters for parallel MSBuild projects (the Visual Studio generator). On the Ninja build the merge rebuilds nothing.
  • LINK: gta6rt.exe links without ws2_32.lib with nothing new over main.
  • A test that would fail without it would build with the Visual Studio generator at -m and check that bcpack_tables.inc is generated once. I did not run the VS generator here.

No blocker from my side.
AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7249329446 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1628#issuecomment-7249329446). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-29T02:17:08Z. --- Tested `3da3c7ffe` merged (no commit) with `main` `53b77df14`. GPUs tested: NVIDIA GeForce RTX 3080, driver 621.40, Windows 11 10.0.26300; MSVC 19.52 (Visual Studio 18), Ninja, RelWithDebInfo; Python 3.12.4. `check_no_game_data.py` is clean. - No test, and no visible effect with Ninja: the change matters for parallel MSBuild projects (the Visual Studio generator). On the Ninja build the merge rebuilds nothing. - LINK: `gta6rt.exe` links without `ws2_32.lib` with nothing new over `main`. - A test that would fail without it would build with the Visual Studio generator at `-m` and check that `bcpack_tables.inc` is generated once. I did not run the VS generator here. No blocker from my side. AI-assisted (Claude Code).
OreoFR commented 2026-11-29 05:47:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T05:47:28Z.


Verified by OreoFR — NO RED (CMake only, no test)

  • Base: main c8bf0e7b6 + this PR (head 3da3c7ffe) merged with --no-ff
  • Red (main + only this PR's tests): none possible: the PR only changes how bcpack_tables.inc is generated (one custom target owns it, plus add_dependencies).
  • Green (merge): full build with Ninja -j 5, no error; ctest (Ninja RelWithDebInfo, all targets, gta6rt launchers excluded) in package p8 = main + #1628 (no shared files): 494 tests, new failures vs main: none (main alone: 494 tests, 5 failures: loader, xs_proxy_mock, xmem_no_write_watch, api_ref_state timeout, xbox_present; xbox_present fails in every package as on main)
  • gta6rt.exe links without the XMA decoder (LEONIDA_CARGO=OFF, LEONIDA_XMA2_DECODER_LIB empty), main + this PR alone; imports unchanged vs main (25 DLLs, 655 functions, no WS2_32)
  • Diff read: no issue (dstorage_test links gta6rt_bcpack, so it is still built after the tables).
  • Other runs: Consistent with zmasi's and TheGeogeo's runs.
  • Machine: Windows 11, Intel Core Ultra 7 155H, RTX 4070 Laptop 8 GB, NVIDIA 621.40, Python 3.12.10, MSVC 19.44

AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7251461635 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1628#issuecomment-7251461635). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T05:47:28Z. --- **Verified by OreoFR** — NO RED (CMake only, no test) - Base: main c8bf0e7b6 + this PR (head 3da3c7ffe) merged with --no-ff - Red (main + only this PR's tests): none possible: the PR only changes how `bcpack_tables.inc` is generated (one custom target owns it, plus `add_dependencies`). - Green (merge): full build with Ninja -j 5, no error; ctest (Ninja RelWithDebInfo, all targets, gta6rt launchers excluded) in package p8 = main + #1628 (no shared files): 494 tests, new failures vs main: none (main alone: 494 tests, 5 failures: loader, xs_proxy_mock, xmem_no_write_watch, api_ref_state timeout, xbox_present; xbox_present fails in every package as on main) - gta6rt.exe links without the XMA decoder (`LEONIDA_CARGO=OFF`, `LEONIDA_XMA2_DECODER_LIB` empty), main + this PR alone; imports unchanged vs main (25 DLLs, 655 functions, no WS2_32) - Diff read: no issue (`dstorage_test` links `gta6rt_bcpack`, so it is still built after the tables). - Other runs: Consistent with zmasi's and TheGeogeo's runs. - Machine: Windows 11, Intel Core Ultra 7 155H, RTX 4070 Laptop 8 GB, NVIDIA 621.40, Python 3.12.10, MSVC 19.44 AI-assisted (Claude Code, Claude Opus 5.5), run for OreoFR.
aslan2142 commented 2026-12-01 10:47:13 +00:00 (Migrated from github.com)

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

Review: APPROVED


Reviewed runtime/CMakeLists.txt: giving bcpack_tables.inc a single add_custom_target(gta6rt_bcpack_tables ...) owner and wiring add_dependencies for bcpack_history_train and gta6rt_bcpack is the canonical CMake fix for the parallel MSBuild double-generation race. Independently verified under both MSBuild /m:4 and Ninja, clean-room compliant, and merges cleanly onto main.

Not merging immediately because the Nov 25 CI run failed on an unrelated stale base (windows, linux-gpu-tools, translator-tests, stdlib-tests-linux, check cancelled). Ready to merge once CI is re-run green on current main.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6129721832 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1628#pullrequestreview-6129721832). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T10:47:13Z. **Review:** APPROVED --- Reviewed `runtime/CMakeLists.txt`: giving `bcpack_tables.inc` a single `add_custom_target(gta6rt_bcpack_tables ...)` owner and wiring `add_dependencies` for `bcpack_history_train` and `gta6rt_bcpack` is the canonical CMake fix for the parallel MSBuild double-generation race. Independently verified under both MSBuild `/m:4` and Ninja, clean-room compliant, and merges cleanly onto `main`. Not merging immediately because the Nov 25 CI run failed on an unrelated stale base (`windows`, `linux-gpu-tools`, `translator-tests`, `stdlib-tests-linux`, `check` cancelled). Ready to merge once CI is re-run green on current `main`. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 16:36:46 +00:00 (Migrated from github.com)

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


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:7317894519 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1628#issuecomment-7317894519). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:36:46Z. --- 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!1628
No description provided.