fix: mod-api builds natively on Windows, with dev.py rt and from source #2961

Closed
neotoxic wants to merge 43 commits from fix/windows-native-rt into mod-api
Contributor

Summary

For mod-api. On Windows, dev.py rt could not make a runtime of mod-api: CI builds the branch on Linux only, and a Windows PC hit four walls in a row; the launcher's build from source (from-source, a pull request's or main's version) hit three more. Each commit is one, with how it failed:

Commit What failed on mod-api, and why
fix(cloth) dev.py rt compiles longshot-builder with mise's Rust, whose Windows host is MSVC. The builder has game-core inside (through api), so cloth's C++ kernels went to cl: no __int128, none of their GCC attributes, builtins and pragmas. The builder never runs the game's cloth, so with an MSVC-like compiler build.rs now compiles one stand-in per function src/ffi.rs declares, read from that file, each saying so and aborting, and says on cargo's output that it did. rust.rs marks the game's own Rust (LONGSHOT_GAME_RUST=1): there an MSVC-like compiler is refused as before, with what to use instead, so a game built for the MSVC target never gets the stand-ins.
fix(script) Then QuickJS-ng in cl: <stdatomic.h> needs C11 and /experimental:c11atomics (upstream's CMake asks both), and Longshot's own longshot_quickjs.c uses GCC's and clang's __atomic_store_n. With cl, build.rs asks for both and includes shim/msvc_atomic.h first (/FI): that store for the aligned int, as a volatile store. third_party/ is untouched.
fix(builder) Then the game's Rust (rust.rs, x86_64-pc-windows-gnullvm): the cmake crate names no compiler for a GNU target on a Windows host, so shaderc-sys's CMake took the first gcc on the PATH (C:\mingw64's), which refuses clang's --target; and its MinGW ar cannot open shaderc's objects, whose paths under the store's work folder reach about 300 characters (the object folder alone is 224). On Windows, from_store now writes a CMake toolchain file from the compilers cargo is given (CC_, CXX_, AR_ of the target) and hands it over as CMAKE_TOOLCHAIN_FILE_<target>; with an archiver, no ranlib step (llvm-ar writes the index).
docs(dev) Before all that, cargo's checkout of oxc (Cargo.toml's [patch.crates-io] to oxc's git tag) stops with path too long under most cargo homes: some of its file names are about 190 characters. libgit2 honours core.longpaths, which setup.md's Windows steps now set. They also name the llvm-ar the previous commit needs on the PATH (rustup's llvm-tools), since tools.lock's trimmed llvm-mingw has none.
fix(from-source) A Windows build from source, by a builder scripts/longshot_builder.py made, stopped three times. gen/shaders was compiled when the pack was made, after the third-party objects, which read its STAMP ("STAMP is missing"); the game's Rust needs it too: it is now compiled first in the pack's stage. The game's Rust was compiled with no C compiler named and no toolchain file, so shaderc's CMake took MinGW's ar again, under the launcher's data folder ("error reading ...opportunity_finder.cpp.obj"): it now gets what rust.rs gives the dev build (CC_, CXX_, AR_ of the source tools' llvm-mingw and windows_cmake's file). The builder it compiled named llvm-mingw's libc++.dll, which no player's PC has, so its pack's check failed (""): it is linked as the release links it (static libc++ and libc++abi, CXXSTDLIB_<target> empty).
test(build-compile) Three checks failed on any Windows PC. testdir named its folder CARGO_MANIFEST_DIR/../../.., which Windows' std::path::absolute resolves and Unix's keeps, so the linker's list and the header package's checks compared two spellings of one path: the root is taken by its ancestors. The MSVC link's check had no lld-link with llvm-mingw ("program not executable"): it places lld as lld-link behind -B, as the MSVC route links. The version tag's check read the PC's global git config, a commit hook among them: its git runs apart from it (GIT_CONFIG_GLOBAL, GIT_CONFIG_NOSYSTEM).

tools.lock's trimmed llvm-mingw has no archiver for that AR_, nor the x86_64-w64-mingw32-clang drivers longshot_builder.py names: that is #2963, the tool bump's pin (releases.md, "Bumping a tool"), then the archive a maintainer publishes, then tools.lock's line in its own pull request, which also changes a player's from-source build on Windows (RenHDrum compiled instead of renhdrum_not_built). Until then dev.py rt takes the llvm-ar on the PATH as setup.md says, and a from-source build the first llvm-ar or ar on the PATH, as before.

Read first: builder/crates/build-compile/src/rust.rs (windows_cmake, from_store), builder/crates/longshot-builder/src/from_source/mod.rs (game_rust_cc), game/crates/cloth/build.rs (msvc_stand_ins).

See #2957 (its comment on the Windows build).

Testing

Tested: Windows 11 Pro (build 26300), RTX 5080, Ryzen 9 9900X3D. mise's Rust 1.99.1 (MSVC host, Visual Studio 2026 Build Tools), tools.lock's tools from dev.py, an llvm-ar on the PATH (rustup's llvm-tools, LLVM 23.1.1), CARGO_HOME short enough for oxc's checkout. No LONGSHOT_BUILD, no CC/CXX set by hand.

  • In the game, dev.py rt then dev.py smoke: PASS, at the head (from kokiri-start: in play, 900 frames, the Insert menu opened; no FATAL line; the game's Rust built for x86_64-pc-windows-gnullvm by llvm-mingw's clang in the store's shared folder; no stand-in line in the game's log). On mod-api the same command stops at each wall above in turn (each seen here, one after the other).
  • The build's time: the first dev.py rt with the toolchain file dropped the -sys crates' builds once (the compilers' record changed) and built the game's Rust in 139.8 s; after a change of the Rust inputs, 107.3 s with no drop (the record is stable, shaderc not configured again); unchanged, dev.py rt takes 8 to 9 s, the library from the store (0.24 s, no cargo). The game's code and the release's programs are built as before.
  • The cloth's guard: on the MSVC host, cargo build -p cloth builds with the stand-ins and says so (warning: [email protected]: ... stand-ins); with LONGSHOT_GAME_RUST=1 it stops with "the cloth's kernels need clang or GCC, not MSVC's compiler: build the Windows game with llvm-mingw ...".
  • Game-free, Windows: cargo fmt --check and cargo clippy --all-targets -D warnings for build-compile, cloth, script; cargo test -p build-compile -p longshot-builder -p script with tools.lock's llvm-mingw on the PATH: everything passes (build-compile 74, longshot-builder 75, their integration tests). cargo test -p script builds QuickJS with cl (92 passed). windows_cmake_takes_the_toolchain_s_compilers_and_archiver is new and runs on any OS. For fix(from-source): cargo clippy -p longshot-builder -p build-compile --all-targets -D warnings passes; the_release_s_flags_name_no_path_of_this_pc now checks the Windows link flags and release_env (empty elsewhere).
  • run_all.py --strict (mise run test), Windows, 32 at once: 781 passed, 26 failed, 49 skipped, at the head and on mod-api @ 1e8153d5 alike: the same 26 fail on both (tools this PC lacks, symbolic links Windows refuses this account, this PC's commit hook): test_audio_output_errors, test_audio_source, test_audio_source_load, test_audio_wave_buffer_release, test_blocks_at_start, test_check_third_party, test_dev_vcs, test_draw_stream_visibility, test_fsr4_tune, test_fsr_uniform_ownership, test_game_font, test_hd_rumble, test_image_reaper_threads, test_lifter, test_longshot_builder, test_pad_headphones_reader, test_pad_speaker, test_readback_timeout_reuse, test_recording_admission, test_rumble_mapping, test_rumble_refresh, test_run_all_output, test_target_retention, test_tex_desc_memo, test_vibration_permission, test_vram_compact.
  • From source, Windows: PASS at the head. scripts/longshot_builder.py build --target windows --profile release with #2963's files (tools.lock's llvm-mingw plus llvm-ar.exe and the two drivers), then that builder's from-source --archive of the head (git archive) under the launcher's data folder (D:\...\LongshotLauncher\work\longshot-builder), MinGW's ar first on the PATH: done in 349 s (183 s compiling; the game's Rust 2 min 06, the builder 3 min 02). shaderc's CMake took the toolchain file naming the source tools' clang.exe, clang++.exe and llvm-ar.exe; the version's Longshot.exe imports no libc++.dll and answers --version. Before this commit the same run stopped at STAMP is missing, then (with that fixed) at shaderc's archive, then at the pack's check.
  • oxc's checkout: the same cargo fetch --locked under a cargo home where its deepest path is 313 characters fails with path too long without core.longpaths, and succeeds with it.
  • Reviewed: a code audit and an independent second read of the diff; their findings are fixed here (the MSVC game target's guard, the tool pin kept for its own pull request, setup.md's llvm-ar line, the comments on clang-cl).

Still to test: None.

Measurements

Nothing to measure in the game: a developer's Windows build only; the game, the release's programs and Linux builds are compiled as before. The build's own times are in Testing.

Risks

  • Windows developer builds and Windows builds from source only. A Windows game build whose PC has no llvm-ar still fails at shaderc's archive, as before; setup.md says where to get one until tools.lock's llvm-mingw carries it.
  • A builder made from source on Windows carries libc++ in its program, as the release's does, instead of naming a DLL. Linux and macOS builds from source are unchanged (release_env is empty there, the flags too).
  • A longshot-builder built by MSVC aborts with a message if anything in it ever called a cloth kernel; nothing does. The game's Rust refuses the stand-ins. The release's Windows builder is built for gnullvm by llvm-mingw, unchanged.
  • Each compile of the builder on Windows' MSVC host prints cloth's warning line.
  • Revert is enough. Nothing changes for players.

Checklist

Ready for review

  • One topic, on current mod-api; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named). The 26 that fail here fail on mod-api too, named in Testing.
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here. windows_cmake_takes_the_toolchain_s_compilers_and_archiver (any OS; on mod-api there is no windows_cmake); on Windows' MSVC host, cargo test -p script and cargo build -p longshot-builder fail to build on mod-api (QuickJS, then cloth's kernels in cl) and pass here.
  • A check under tests/ that reads changed source is updated, not weakened. Those reading cloth's and script's build.rs (test_game_boundary.py, test_mise_build.py) needed no change and pass.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary For `mod-api`. On Windows, `dev.py rt` could not make a runtime of `mod-api`: CI builds the branch on Linux only, and a Windows PC hit four walls in a row; the launcher's build from source (`from-source`, a pull request's or main's version) hit three more. Each commit is one, with how it failed: | Commit | What failed on `mod-api`, and why | |---|---| | `fix(cloth)` | `dev.py rt` compiles `longshot-builder` with mise's Rust, whose Windows host is MSVC. The builder has `game-core` inside (through `api`), so `cloth`'s C++ kernels went to `cl`: no `__int128`, none of their GCC attributes, builtins and pragmas. The builder never runs the game's cloth, so with an MSVC-like compiler `build.rs` now compiles one stand-in per function `src/ffi.rs` declares, read from that file, each saying so and aborting, and says on cargo's output that it did. `rust.rs` marks the game's own Rust (`LONGSHOT_GAME_RUST=1`): there an MSVC-like compiler is refused as before, with what to use instead, so a game built for the MSVC target never gets the stand-ins. | | `fix(script)` | Then QuickJS-ng in `cl`: `<stdatomic.h>` needs C11 and `/experimental:c11atomics` (upstream's CMake asks both), and Longshot's own `longshot_quickjs.c` uses GCC's and clang's `__atomic_store_n`. With `cl`, `build.rs` asks for both and includes `shim/msvc_atomic.h` first (`/FI`): that store for the aligned `int`, as a volatile store. `third_party/` is untouched. | | `fix(builder)` | Then the game's Rust (`rust.rs`, `x86_64-pc-windows-gnullvm`): the cmake crate names no compiler for a GNU target on a Windows host, so `shaderc-sys`'s CMake took the first `gcc` on the PATH (`C:\mingw64`'s), which refuses clang's `--target`; and its MinGW `ar` cannot open shaderc's objects, whose paths under the store's work folder reach about 300 characters (the object folder alone is 224). On Windows, `from_store` now writes a CMake toolchain file from the compilers cargo is given (`CC_`, `CXX_`, `AR_` of the target) and hands it over as `CMAKE_TOOLCHAIN_FILE_<target>`; with an archiver, no ranlib step (llvm-ar writes the index). | | `docs(dev)` | Before all that, cargo's checkout of oxc (Cargo.toml's `[patch.crates-io]` to oxc's git tag) stops with `path too long` under most cargo homes: some of its file names are about 190 characters. libgit2 honours `core.longpaths`, which setup.md's Windows steps now set. They also name the `llvm-ar` the previous commit needs on the PATH (rustup's `llvm-tools`), since tools.lock's trimmed llvm-mingw has none. | | `fix(from-source)` | A Windows build from source, by a builder `scripts/longshot_builder.py` made, stopped three times. `gen/shaders` was compiled when the pack was made, after the third-party objects, which read its `STAMP` ("STAMP is missing"); the game's Rust needs it too: it is now compiled first in the pack's stage. The game's Rust was compiled with no C compiler named and no toolchain file, so shaderc's CMake took MinGW's `ar` again, under the launcher's data folder ("error reading ...opportunity_finder.cpp.obj"): it now gets what `rust.rs` gives the dev build (`CC_`, `CXX_`, `AR_` of the source tools' llvm-mingw and `windows_cmake`'s file). The builder it compiled named llvm-mingw's `libc++.dll`, which no player's PC has, so its pack's check failed (`""`): it is linked as the release links it (static libc++ and libc++abi, `CXXSTDLIB_<target>` empty). | | `test(build-compile)` | Three checks failed on any Windows PC. `testdir` named its folder `CARGO_MANIFEST_DIR/../../..`, which Windows' `std::path::absolute` resolves and Unix's keeps, so the linker's list and the header package's checks compared two spellings of one path: the root is taken by its ancestors. The MSVC link's check had no `lld-link` with llvm-mingw ("program not executable"): it places lld as `lld-link` behind `-B`, as the MSVC route links. The version tag's check read the PC's global git config, a commit hook among them: its git runs apart from it (`GIT_CONFIG_GLOBAL`, `GIT_CONFIG_NOSYSTEM`). | tools.lock's trimmed llvm-mingw has no archiver for that `AR_`, nor the `x86_64-w64-mingw32-clang` drivers `longshot_builder.py` names: that is #2963, the tool bump's pin (`releases.md`, "Bumping a tool"), then the archive a maintainer publishes, then tools.lock's line in its own pull request, which also changes a player's from-source build on Windows (RenHDrum compiled instead of `renhdrum_not_built`). Until then `dev.py rt` takes the `llvm-ar` on the PATH as setup.md says, and a from-source build the first `llvm-ar` or `ar` on the PATH, as before. Read first: `builder/crates/build-compile/src/rust.rs` (`windows_cmake`, `from_store`), `builder/crates/longshot-builder/src/from_source/mod.rs` (`game_rust_cc`), `game/crates/cloth/build.rs` (`msvc_stand_ins`). See #2957 (its comment on the Windows build). ## Testing **Tested:** Windows 11 Pro (build 26300), RTX 5080, Ryzen 9 9900X3D. mise's Rust 1.99.1 (MSVC host, Visual Studio 2026 Build Tools), tools.lock's tools from `dev.py`, an `llvm-ar` on the PATH (rustup's llvm-tools, LLVM 23.1.1), `CARGO_HOME` short enough for oxc's checkout. No `LONGSHOT_BUILD`, no `CC`/`CXX` set by hand. - **In the game, `dev.py rt` then `dev.py smoke`: PASS**, at the head (from `kokiri-start`: in play, 900 frames, the Insert menu opened; no FATAL line; the game's Rust built for `x86_64-pc-windows-gnullvm` by llvm-mingw's clang in the store's shared folder; no stand-in line in the game's log). On `mod-api` the same command stops at each wall above in turn (each seen here, one after the other). - **The build's time:** the first `dev.py rt` with the toolchain file dropped the -sys crates' builds once (the compilers' record changed) and built the game's Rust in 139.8 s; after a change of the Rust inputs, 107.3 s with no drop (the record is stable, shaderc not configured again); unchanged, `dev.py rt` takes 8 to 9 s, the library from the store (0.24 s, no cargo). The game's code and the release's programs are built as before. - **The cloth's guard:** on the MSVC host, `cargo build -p cloth` builds with the stand-ins and says so (`warning: [email protected]: ... stand-ins`); with `LONGSHOT_GAME_RUST=1` it stops with "the cloth's kernels need clang or GCC, not MSVC's compiler: build the Windows game with llvm-mingw ...". - **Game-free, Windows:** `cargo fmt --check` and `cargo clippy --all-targets -D warnings` for `build-compile`, `cloth`, `script`; `cargo test -p build-compile -p longshot-builder -p script` with tools.lock's llvm-mingw on the PATH: everything passes (build-compile 74, longshot-builder 75, their integration tests). `cargo test -p script` builds QuickJS with `cl` (92 passed). `windows_cmake_takes_the_toolchain_s_compilers_and_archiver` is new and runs on any OS. For `fix(from-source)`: `cargo clippy -p longshot-builder -p build-compile --all-targets -D warnings` passes; `the_release_s_flags_name_no_path_of_this_pc` now checks the Windows link flags and `release_env` (empty elsewhere). - **`run_all.py --strict` (`mise run test`), Windows, 32 at once:** 781 passed, 26 failed, 49 skipped, at the head and on `mod-api` @ 1e8153d5 alike: the same 26 fail on both (tools this PC lacks, symbolic links Windows refuses this account, this PC's commit hook): `test_audio_output_errors`, `test_audio_source`, `test_audio_source_load`, `test_audio_wave_buffer_release`, `test_blocks_at_start`, `test_check_third_party`, `test_dev_vcs`, `test_draw_stream_visibility`, `test_fsr4_tune`, `test_fsr_uniform_ownership`, `test_game_font`, `test_hd_rumble`, `test_image_reaper_threads`, `test_lifter`, `test_longshot_builder`, `test_pad_headphones_reader`, `test_pad_speaker`, `test_readback_timeout_reuse`, `test_recording_admission`, `test_rumble_mapping`, `test_rumble_refresh`, `test_run_all_output`, `test_target_retention`, `test_tex_desc_memo`, `test_vibration_permission`, `test_vram_compact`. - **From source, Windows: PASS** at the head. `scripts/longshot_builder.py build --target windows --profile release` with #2963's files (tools.lock's llvm-mingw plus `llvm-ar.exe` and the two drivers), then that builder's `from-source --archive` of the head (`git archive`) under the launcher's data folder (`D:\...\LongshotLauncher\work\longshot-builder`), MinGW's `ar` first on the PATH: done in 349 s (183 s compiling; the game's Rust 2 min 06, the builder 3 min 02). shaderc's CMake took the toolchain file naming the source tools' `clang.exe`, `clang++.exe` and `llvm-ar.exe`; the version's `Longshot.exe` imports no `libc++.dll` and answers `--version`. Before this commit the same run stopped at `STAMP is missing`, then (with that fixed) at shaderc's archive, then at the pack's check. - **oxc's checkout:** the same `cargo fetch --locked` under a cargo home where its deepest path is 313 characters fails with `path too long` without `core.longpaths`, and succeeds with it. - **Reviewed:** a code audit and an independent second read of the diff; their findings are fixed here (the MSVC game target's guard, the tool pin kept for its own pull request, setup.md's `llvm-ar` line, the comments on clang-cl). **Still to test:** None. ## Measurements Nothing to measure in the game: a developer's Windows build only; the game, the release's programs and Linux builds are compiled as before. The build's own times are in Testing. ## Risks - Windows developer builds and Windows builds from source only. A Windows game build whose PC has no `llvm-ar` still fails at shaderc's archive, as before; setup.md says where to get one until tools.lock's llvm-mingw carries it. - A builder made from source on Windows carries libc++ in its program, as the release's does, instead of naming a DLL. Linux and macOS builds from source are unchanged (`release_env` is empty there, the flags too). - A `longshot-builder` built by MSVC aborts with a message if anything in it ever called a cloth kernel; nothing does. The game's Rust refuses the stand-ins. The release's Windows builder is built for gnullvm by llvm-mingw, unchanged. - Each compile of the builder on Windows' MSVC host prints cloth's warning line. - Revert is enough. Nothing changes for players. ## Checklist ### Ready for review - [x] One topic, on current `mod-api`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). The 26 that fail here fail on `mod-api` too, named in Testing. - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. `windows_cmake_takes_the_toolchain_s_compilers_and_archiver` (any OS; on `mod-api` there is no `windows_cmake`); on Windows' MSVC host, `cargo test -p script` and `cargo build -p longshot-builder` fail to build on `mod-api` (QuickJS, then cloth's kernels in `cl`) and pass here. - [x] A check under `tests/` that reads changed source is updated, not weakened. Those reading cloth's and script's `build.rs` (`test_game_boundary.py`, `test_mise_build.py`) needed no change and pass. - [x] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [x] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
`dev.py rt` on Windows compiles longshot-builder with mise's Rust, whose
host is x86_64-pc-windows-msvc. The builder has game-core inside (through
api), so cargo builds this crate's C++ kernels with cl, which has no
__int128 and none of their GCC attributes, builtins and pragmas: the
compile stopped there (cl's errors on its stdout, which cc keeps).

The builder never runs the game's cloth: the game is another program, and
its Rust is built for x86_64-pc-windows-gnullvm by llvm-mingw's clang
(build-compile's rust.rs), where the kernels compile as before. With an
MSVC-like compiler, build.rs now compiles one stand-in for each function
src/ffi.rs's extern block declares (read from the file, so none is
missed), which says so on stderr and aborts.

Check: `cargo build --release -p longshot-builder` on Windows' MSVC host
stopped in cloth's build script on mod-api; it builds here, and
`dev.py rt` then `dev.py smoke` pass (the game's own cloth built by clang,
no stand-in line in its log).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The same MSVC-host longshot-builder compile then stopped in the script
crate: QuickJS-ng includes <stdatomic.h>, which cl gives only in C11 mode
with its C11 atomics turned on (upstream's CMake asks for both), and
Longshot's own longshot_quickjs.c (PROVENANCE.md's `local:` file, not
upstream's) stored the interrupt counter with GCC's __atomic_store_n,
which cl does not have.

build.rs asks cl for C11 and /experimental:c11atomics; longshot_quickjs.c
stores the counter through a macro: __atomic_store_n(relaxed) as before
with GCC and clang, a volatile int store with cl (what a relaxed store of
an aligned int is on x86-64 and Arm64).

Check: `cargo test -p script` on Windows' MSVC host fails to build on
mod-api; here it builds QuickJS with cl and its tests pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A developer's game build on Windows compiles the game's Rust for
x86_64-pc-windows-gnullvm (rust.rs). shaderc-sys configures shaderc with
CMake through the cmake crate, which on a Windows host names no compiler
for a GNU target ("for MinGW it doesn't really vary"): CMake took the first
gcc on the PATH (here C:\mingw64's), which refuses clang's --target flags,
so the configure failed; with a gcc it accepted, its MinGW ar could not
open shaderc's objects, whose paths under the store's work folder reach
about 300 characters (the object folder alone is 224 under
D:\...\longshot-dev\store\compile\v1\rust\work\<key>\target\...).

On Windows, from_store now writes a CMake toolchain file in the shared
work folder from the compilers cargo is given (CC_, CXX_ and AR_ of the
target: llvm-mingw's clang and clang++, and llvm-ar when there is one,
with no ranlib step, since llvm-ar writes the index) and hands it to the
cmake crate (CMAKE_TOOLCHAIN_FILE_<target>). The variable is part of the
compilers' record, so a target folder configured before drops its -sys
builds once.

Check: windows_cmake_takes_the_toolchain_s_compilers_and_archiver (any
OS). In the game: `dev.py rt` on Windows 11 built the game's Rust with
llvm-mingw's clang and an llvm-ar on the PATH, then `dev.py smoke` passed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
tools.lock's trimmed llvm-mingw has no archiver, so a game build on
Windows archives the game's Rust's C, C++ and CMake objects with whatever
ar the PC has: none on a clean PC, or MinGW's, which cannot open a path
past 260 characters (shaderc's, previous commit). llvm-ar.exe goes in the
trim (it loads libLLVM-<n>.dll, already there), and LLVM_MINGW_TRIM is 2:
a new package version, which make.sh builds and the release's
longshot-tools workflow uploads, then tools.lock names. Until then, an
llvm-ar on the PATH does (rustup's llvm-tools component has one).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
docs(dev): on Windows, git's core.longpaths for cargo's checkout of oxc
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
e42b07496c
Cargo.toml patches the oxc crates to oxc's git tag, so cargo checks out
oxc's whole repository into its cargo home with libgit2. Some of its file
names are about 190 characters (apps/oxlint/src/snapshots/...), so under
most cargo homes the checkout passes 260 and cargo stops: `path too long`.
libgit2 honours git's core.longpaths: with it in the global config the
same checkout succeeds (checked under a cargo home where the path reached
313 characters; without it, the same command fails).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
neotoxic force-pushed fix/windows-native-rt from e42b07496c
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
to 8d516c85f4
All checks were successful
PR description / Title and description (pull_request_target) Successful in 7s
2026-12-01 18:44:16 +00:00
Compare
neotoxic changed title from WIP: fix: mod-api's game builds natively on Windows with dev.py rt to fix: mod-api's game builds natively on Windows with dev.py rt 2026-12-01 18:44:22 +00:00
Member
@review
BeanBot left a comment

Recommendation: Approve. The Windows build now succeeds on the tested setup, but the compiler check can select the wrong cloth implementation, and the new MSVC interrupt store races with the interpreter thread. The stand-ins also leave the cloth tests unable to link on MSVC. Nothing blocking is left. Recommend approval; not approved on the forge.

The change enables the tested Windows developer runtime build by supplying cloth stand-ins to the builder, adapting QuickJS for MSVC, and directing CMake to the selected Windows toolchain. It adds a compiler-dependent fallback that needs tighter boundaries and synchronization.

Should fix (4): not blocking, but worth doing before merging.

  • L1 game/crates/cloth/build.rs:30: The compiler is detected before enabling C++ mode, so this checks CC rather than the CXX that will compile the kernels. (more on the line) Do: Detect the compiler using a C++ configured build, and use a separate C build for the stand-ins. Cover differing CC and CXX selections.
  • L2 game/crates/script/shim/msvc_atomic.h:9: A volatile store does not synchronize with the interpreter's ordinary accesses to interrupt_counter; the new MSVC path has a C data race. (more on the line) Do: Make all concurrent accesses to the counter atomic, including QuickJS's decrement and reset, or use another synchronization design that covers both threads.
  • L3 game/crates/cloth/build.rs:76: The generated stand-ins omit the cloth_layout symbol required by the crate's tests. (more on the line) Do: Provide a meaningful MSVC-compatible layout check or explicitly arrange for the kernel-dependent tests to run with a supported C++ compiler; ensure the workspace test command has a working Windows configuration.
  • L4 game/crates/cloth/build.rs:32: The game-library guard relies on a marker set by only one of the ways to build the Rust library. (more on the line) Do: Make stand-ins an explicit builder-only feature or otherwise ensure every game-library build rejects them by default.

@fix can do L1, L2, L3 and L4.

More: does it help, other systems, switches, what was read

Does it help: Yes for the reported setup: the author reports that dev.py rt and a 900-frame smoke run passed on Windows 11 after the base stopped at the described build failures. Build times are reported for the head, but no comparable base build time is available because the base failed.

Other systems: The cloth compiler selection also depends on independently configured CC and CXX. The QuickJS shim affects MSVC and clang-cl builds, including script tests and any program using the script crate. The Windows CMake file affects CMake-based dependencies in developer game builds; Linux does not enter that path. The reported game run covers NVIDIA Windows, not other Windows toolchain configurations.

Switches: LONGSHOT_GAME_RUST is added as an internal build marker, absent by default and set to 1 by build-compile for its game Rust build. Its protection depends on every game-library build setting it; direct cargo builds do not.

Reviewed: 8d516c85f4 against 1e8153d50d: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the diff and commit messages, cloth/build.rs, script/build.rs, msvc_atomic.h, cloth's FFI declarations, and build-compile's rust.rs. Read the relevant setup and standards rules and traced the toolchain, watchdog, QuickJS counter, workspace tests, and other game Rust build paths. docs/review-checklist.md and the adjacent Tooling checkout were absent. The long setup and standards documents and unchanged surrounding files were skimmed.; nothing run (a code review).

Checked and fine:

  • The current FFI function declarations are all picked up by the stand-in generator.
  • The shared Rust work folder is locked before the toolchain file is written.
  • The commits carry AI assistance trailers; the diff contains no game-derived output or third-party edits.
  • The supplied CI record has no head-only failures.

Testing: No commands from the project or tests were run, as requested. The author reports a Windows runtime build and smoke run, script tests, and comparison of the listed game-free check failures against the base.

Overlaps and merge order: Not checked: the network is closed and no overlapping pull requests were supplied.


Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The Windows build now succeeds on the tested setup, but the compiler check can select the wrong cloth implementation, and the new MSVC interrupt store races with the interpreter thread. The stand-ins also leave the cloth tests unable to link on MSVC. Nothing blocking is left. Recommend approval; not approved on the forge. The change enables the tested Windows developer runtime build by supplying cloth stand-ins to the builder, adapting QuickJS for MSVC, and directing CMake to the selected Windows toolchain. It adds a compiler-dependent fallback that needs tighter boundaries and synchronization. **Should fix (4)**: not blocking, but worth doing before merging. - **L1** `game/crates/cloth/build.rs:30`: The compiler is detected before enabling C++ mode, so this checks CC rather than the CXX that will compile the kernels. (more on the line) **Do:** Detect the compiler using a C++ configured build, and use a separate C build for the stand-ins. Cover differing CC and CXX selections. - **L2** `game/crates/script/shim/msvc_atomic.h:9`: A volatile store does not synchronize with the interpreter's ordinary accesses to interrupt_counter; the new MSVC path has a C data race. (more on the line) **Do:** Make all concurrent accesses to the counter atomic, including QuickJS's decrement and reset, or use another synchronization design that covers both threads. - **L3** `game/crates/cloth/build.rs:76`: The generated stand-ins omit the cloth_layout symbol required by the crate's tests. (more on the line) **Do:** Provide a meaningful MSVC-compatible layout check or explicitly arrange for the kernel-dependent tests to run with a supported C++ compiler; ensure the workspace test command has a working Windows configuration. - **L4** `game/crates/cloth/build.rs:32`: The game-library guard relies on a marker set by only one of the ways to build the Rust library. (more on the line) **Do:** Make stand-ins an explicit builder-only feature or otherwise ensure every game-library build rejects them by default. `@fix` can do L1, L2, L3 and L4. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes for the reported setup: the author reports that dev.py rt and a 900-frame smoke run passed on Windows 11 after the base stopped at the described build failures. Build times are reported for the head, but no comparable base build time is available because the base failed. **Other systems:** The cloth compiler selection also depends on independently configured CC and CXX. The QuickJS shim affects MSVC and clang-cl builds, including script tests and any program using the script crate. The Windows CMake file affects CMake-based dependencies in developer game builds; Linux does not enter that path. The reported game run covers NVIDIA Windows, not other Windows toolchain configurations. **Switches:** LONGSHOT_GAME_RUST is added as an internal build marker, absent by default and set to 1 by build-compile for its game Rust build. Its protection depends on every game-library build setting it; direct cargo builds do not. **Reviewed:** 8d516c85f4c6 against 1e8153d50d7c: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the diff and commit messages, cloth/build.rs, script/build.rs, msvc_atomic.h, cloth's FFI declarations, and build-compile's rust.rs. Read the relevant setup and standards rules and traced the toolchain, watchdog, QuickJS counter, workspace tests, and other game Rust build paths. docs/review-checklist.md and the adjacent Tooling checkout were absent. The long setup and standards documents and unchanged surrounding files were skimmed.; nothing run (a code review). **Checked and fine:** - The current FFI function declarations are all picked up by the stand-in generator. - The shared Rust work folder is locked before the toolchain file is written. - The commits carry AI assistance trailers; the diff contains no game-derived output or third-party edits. - The supplied CI record has no head-only failures. **Testing:** No commands from the project or tests were run, as requested. The author reports a Windows runtime build and smoke run, script tests, and comparison of the listed game-free check failures against the base. **Overlaps and merge order:** Not checked: the network is closed and no overlapping pull requests were supplied. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.</sub>
@ -27,2 +27,4 @@
fn main() {
let mut b = cc::Build::new();
println!("cargo:rerun-if-env-changed=LONGSHOT_GAME_RUST");
if b.get_compiler().is_like_msvc() {
Member

L1 (should fix): The compiler is detected before enabling C++ mode, so this checks CC rather than the CXX that will compile the kernels.

When: With CC set to cl and CXX set to a working clang++ or GCC, the build selects aborting stand-ins, or rejects a game build, even though its C++ compiler can compile the kernels. With CC set to clang and CXX to cl, it instead sends the GCC-style kernel options to cl and fails.

Do: Detect the compiler using a C++ configured build, and use a separate C build for the stand-ins. Cover differing CC and CXX selections.

**L1** (should fix): The compiler is detected before enabling C++ mode, so this checks CC rather than the CXX that will compile the kernels. *When:* With CC set to cl and CXX set to a working clang++ or GCC, the build selects aborting stand-ins, or rejects a game build, even though its C++ compiler can compile the kernels. With CC set to clang and CXX to cl, it instead sends the GCC-style kernel options to cl and fails. **Do:** Detect the compiler using a C++ configured build, and use a separate C build for the stand-ins. Cover differing CC and CXX selections.
@ -29,0 +29,4 @@
println!("cargo:rerun-if-env-changed=LONGSHOT_GAME_RUST");
if b.get_compiler().is_like_msvc() {
// (the game's own Rust, which build-compile's rust.rs marks: the game runs the kernels, so never stand-ins there)
if std::env::var_os("LONGSHOT_GAME_RUST").is_some() {
Member

L4 (should fix): The game-library guard relies on a marker set by only one of the ways to build the Rust library.

When: A direct cargo build -p longshot-rs for the MSVC target does not set LONGSHOT_GAME_RUST, so it succeeds with aborting cloth functions. Linking and running that library aborts when a cloth kernel is called.

Do: Make stand-ins an explicit builder-only feature or otherwise ensure every game-library build rejects them by default.

**L4** (should fix): The game-library guard relies on a marker set by only one of the ways to build the Rust library. *When:* A direct cargo build -p longshot-rs for the MSVC target does not set LONGSHOT_GAME_RUST, so it succeeds with aborting cloth functions. Linking and running that library aborts when a cloth kernel is called. **Do:** Make stand-ins an explicit builder-only feature or otherwise ensure every game-library build rejects them by default.
@ -51,0 +73,4 @@
let block = ffi.split("unsafe extern \"C\" {").nth(1).expect("src/ffi.rs: its unsafe extern \"C\" block");
let block = &block[..block.find("\n}").expect("the extern block's end")];
let mut c = String::from("#include <stdio.h>\n#include <stdlib.h>\n");
for line in block.lines().map(str::trim) {
Member

L3 (should fix): The generated stand-ins omit the cloth_layout symbol required by the crate's tests.

When: On an MSVC host, cargo test -p cloth builds the stand-ins, but the test's c_layout references cloth_layout, which neither the generated C file nor the skipped layout.cpp defines, so the test binary cannot link.

Do: Provide a meaningful MSVC-compatible layout check or explicitly arrange for the kernel-dependent tests to run with a supported C++ compiler; ensure the workspace test command has a working Windows configuration.

**L3** (should fix): The generated stand-ins omit the cloth_layout symbol required by the crate's tests. *When:* On an MSVC host, cargo test -p cloth builds the stand-ins, but the test's c_layout references cloth_layout, which neither the generated C file nor the skipped layout.cpp defines, so the test binary cannot link. **Do:** Provide a meaningful MSVC-compatible layout check or explicitly arrange for the kernel-dependent tests to run with a supported C++ compiler; ensure the workspace test command has a working Windows configuration.
@ -0,0 +6,4 @@
#ifndef LONGSHOT_MSVC_ATOMIC_H
#define LONGSHOT_MSVC_ATOMIC_H
#define __ATOMIC_RELAXED 0
#define __atomic_store_n(p, v, order) ((void)(order), *(volatile int *)(p) = (v))
Member

L2 (should fix): A volatile store does not synchronize with the interpreter's ordinary accesses to interrupt_counter; the new MSVC path has a C data race.

When: While a script runs, the watchdog can call poll_soon and write the counter while QuickJS decrements or resets it. The accesses are concurrent and unprotected, so the compiler is not required to preserve the intended interrupt behavior.

Do: Make all concurrent accesses to the counter atomic, including QuickJS's decrement and reset, or use another synchronization design that covers both threads.

**L2** (should fix): A volatile store does not synchronize with the interpreter's ordinary accesses to interrupt_counter; the new MSVC path has a C data race. *When:* While a script runs, the watchdog can call poll_soon and write the counter while QuickJS decrements or resets it. The accesses are concurrent and unprotected, so the compiler is not required to preserve the intended interrupt behavior. **Do:** Make all concurrent accesses to the counter atomic, including QuickJS's decrement and reset, or use another synchronization design that covers both threads.
neotoxic force-pushed fix/windows-native-rt from 8d516c85f4
All checks were successful
PR description / Title and description (pull_request_target) Successful in 7s
to eb02178f57
All checks were successful
PR description / Title and description (pull_request_target) Successful in 7s
2026-12-02 01:58:08 +00:00
Compare
Author
Contributor

Thanks: all four done in eb02178f (rebased on mod-api e132adfa).

  • L1: the cloth's compiler is judged with C++ on (b.cpp(true) before get_compiler()), so by the CXX that compiles the kernels; the stand-ins, plain C, are built by a C build of their own (CC, whichever it is).
  • L2: the MSVC store is now Windows' atomic _InterlockedExchange on the long the int is, not a volatile one. The interpreter's own decrement stays upstream's plain int on every compiler (quickjs.c is unmodified), as on the GCC path: a store that lands inside it is lost, and the watchdog stores again at each tick (longshot_quickjs.c says so).
  • L3: with stand-ins the crate emits cfg(cloth_stand_ins), which leaves out the tests that need the kernels (cloth_layout's among them); cargo test -p cloth links on MSVC and the rest runs (14 with GNU).
  • L4: longshot-rs has a build script that refuses the MSVC target, so a direct cargo build -p longshot-rs for MSVC stops with what to do; build-compile's marker stays as a second guard.

Checked: with the MSVC toolchain, cargo build -p longshot-rs refused, cargo test -p cloth links, cargo test -p script (92 passed); with GNU, cargo test -p cloth and clippy; on Windows 11 again, dev.py rt and dev.py smoke PASS (in play from kokiri-start, 900 frames, the menu opened).

Thanks: all four done in eb02178f (rebased on mod-api e132adfa). - **L1**: the cloth's compiler is judged with C++ on (`b.cpp(true)` before `get_compiler()`), so by the CXX that compiles the kernels; the stand-ins, plain C, are built by a C build of their own (CC, whichever it is). - **L2**: the MSVC store is now Windows' atomic `_InterlockedExchange` on the `long` the int is, not a volatile one. The interpreter's own decrement stays upstream's plain `int` on every compiler (`quickjs.c` is unmodified), as on the GCC path: a store that lands inside it is lost, and the watchdog stores again at each tick (`longshot_quickjs.c` says so). - **L3**: with stand-ins the crate emits `cfg(cloth_stand_ins)`, which leaves out the tests that need the kernels (`cloth_layout`'s among them); `cargo test -p cloth` links on MSVC and the rest runs (14 with GNU). - **L4**: `longshot-rs` has a build script that refuses the MSVC target, so a direct `cargo build -p longshot-rs` for MSVC stops with what to do; build-compile's marker stays as a second guard. Checked: with the MSVC toolchain, `cargo build -p longshot-rs` refused, `cargo test -p cloth` links, `cargo test -p script` (92 passed); with GNU, `cargo test -p cloth` and clippy; on Windows 11 again, `dev.py rt` and `dev.py smoke` PASS (in play from kokiri-start, 900 frames, the menu opened).
fix(from-source): a Windows build from source makes a builder that starts
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
9e3384336c
A build from source on Windows (the launcher's for a pull request or main) stopped four times:
- gen/shaders was compiled when the pack was made, after the third-party objects, which read its
  STAMP and stopped first ("STAMP is missing"); the game's Rust (the api crate) needs it too. It is
  now compiled first thing in the pack's stage.
- the builder it compiled named llvm-mingw's libc++.dll (glslang's C++, shaderc-sys's), a DLL no
  player's PC has: the program did not start, so its pack's check failed ("does not read the pack
  ... (\"\")"). It is now linked as the release links it (scripts/longshot_builder.py): libc++ and
  libc++abi static, CXXSTDLIB_<target> empty.
- the game's Rust was compiled with no C compiler named and no CMake toolchain file, so shaderc's
  CMake took the first `ar` on the PATH (MinGW's, which cannot open its objects past 260 characters
  under the launcher's data folder: "error reading ...opportunity_finder.cpp.obj"). It now gets what
  build-compile's rust.rs gives the dev build: CC, CXX and AR of the source tools' llvm-mingw, and
  the CMake toolchain file that names them (windows_cmake, drop_stale_sys, now public).
- tools.lock's trimmed llvm-mingw has no archiver for that AR. Its recipe now keeps
  llvm-ar.exe (65 KB, on the libLLVM DLL it keeps already), and llvm-mingw's two x86-64 drivers
  (x86_64-w64-mingw32-clang, -clang++: 14 KB each), which scripts/longshot_builder.py's Windows build
  and build-compile's rust.rs look for: LLVM_MINGW_TRIM 2. The archive is a maintainer's to publish
  (releases.md, "Bumping a tool"), then tools.lock's line.

Checked on Windows 11 with that recipe's files: scripts/longshot_builder.py build --target windows,
then that builder's from-source --archive of this commit under the launcher's data folder
(D:\...\work\longshot-builder, MinGW's ar first on the PATH): shaderc's CMakeCache names llvm-ar,
the version folder is made, its Longshot.exe imports no libc++.dll and answers --version.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
neotoxic changed title from fix: mod-api's game builds natively on Windows with dev.py rt to fix: mod-api builds natively on Windows, with dev.py rt and from source 2026-12-02 03:29:01 +00:00
neotoxic force-pushed fix/windows-native-rt from 9e3384336c
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
to e1acaf6b18
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
2026-12-02 03:29:46 +00:00
Compare
test(build-compile): three checks that failed on any Windows PC pass there
All checks were successful
PR description / Title and description (pull_request_target) Successful in 6s
2927672de3
- testdir named its folder by CARGO_MANIFEST_DIR/../../..: Windows' std::path::absolute resolves
  `..`, Unix's keeps it, so the_linker_s_list_is_parted_from_its_output and
  a_header_package_too_old_is_no_package compared a path the code made absolute with the test's own
  and differed on Windows only. The root is now taken by its ancestors.
- a_windows_link_of_the_same_inputs_makes_the_same_bytes linked for the MSVC target with
  -fuse-ld=lld and nothing else: llvm-mingw has no lld-link ("program not executable"). It now places
  lld as lld-link and passes it through -B, as the MSVC route links (place_lld_link).
- a_checkout_is_named_by_its_version_tag's repository read the PC's global git config, a commit hook
  that refuses its t@t among them. Its git runs apart from it (GIT_CONFIG_GLOBAL to a file that is
  not there, GIT_CONFIG_NOSYSTEM).

Checked on Windows 11 with tools.lock's llvm-mingw on the PATH: cargo test -p build-compile
-p longshot-builder, everything passes (74 and 75 in the libraries); clippy --all-targets clean.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member
@review
BeanBot left a comment

Recommendation: Approve. The Windows build paths have reported successful runs, but the watchdog counter still has the data race identified in L2. Nothing blocking is left. Recommend approval; not approved on the forge.

The change enables Windows developer and from-source builds through compiler, shader-generation and linking fixes. It adds platform-specific build logic and stand-ins for cloth kernels in the MSVC-built builder.

Should fix (1): not blocking, but worth doing before merging.

  • L2 game/crates/script/shim/msvc_atomic.h:9: The interlocked store does not make the interpreter's ordinary accesses to interrupt_counter atomic, so the data race remains. When: While the watchdog calls longshot_qjs_poll_soon from its thread, QuickJS can decrement or reset interrupt_counter on the interpreter thread; those conflicting accesses are not synchronized. Do: Make every concurrent access to the counter atomic, or synchronize the watchdog and interpreter accesses through a shared mechanism.

@fix can do L2.

Since the last review (on 8d516c85f4)
Resolved: L1 (The compiler is detected before enabling C++ mode, so this checks CC rather than the CXX t…); L3 (The generated stand-ins omit the cloth_layout symbol required by the crate's tests.); L4 (The game-library guard relies on a marker set by only one of the ways to build the Rust li…)
Still open: L2 (The interlocked store does not make the interpreter's ordinary accesses to interrupt_count…)

More: does it help, other systems, switches, what was read

Does it help: Yes. The author reports that Windows dev.py rt and smoke passed, and that a Windows from-source build completed in 349 seconds; the corresponding builds previously stopped at the described failures. This is not a game performance change.

Other systems: The changes affect Windows developer builds, Windows from-source builds, and MSVC-hosted crate builds. The author reports Windows game and build checks; Linux builds and other compiler combinations are not evidenced by a new run.

Switches: LONGSHOT_GAME_RUST is added as an internal build marker, absent by default and set by the developer game Rust build; it rejects cloth stand-ins for that build.

Reviewed: 2927672de3 against e132adfa0c: Read the repository rules and pull request template, the cloth build script, script build script, atomic shim, game-library build script, and the relevant diffs and watchdog references. The remaining changed files and their surrounding code were skimmed rather than read in full; Tooling's separate repository rules were unavailable.; nothing run (a code review).

Checked and fine:

  • The game-library MSVC target guard covers direct cargo builds.
  • The reported Windows run exercised both the developer runtime and from-source build.

Testing: No commands that build or run the project were executed. The author reports Windows game, build and crate checks; the supplied CI has no head-only failures.

Overlaps and merge order: The description identifies #2963 as the separate tool archive and pin needed for the complete Windows from-source toolchain.


Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The Windows build paths have reported successful runs, but the watchdog counter still has the data race identified in L2. Nothing blocking is left. Recommend approval; not approved on the forge. The change enables Windows developer and from-source builds through compiler, shader-generation and linking fixes. It adds platform-specific build logic and stand-ins for cloth kernels in the MSVC-built builder. **Should fix (1)**: not blocking, but worth doing before merging. - **L2** `game/crates/script/shim/msvc_atomic.h:9`: The interlocked store does not make the interpreter's ordinary accesses to interrupt_counter atomic, so the data race remains. *When:* While the watchdog calls longshot_qjs_poll_soon from its thread, QuickJS can decrement or reset interrupt_counter on the interpreter thread; those conflicting accesses are not synchronized. **Do:** Make every concurrent access to the counter atomic, or synchronize the watchdog and interpreter accesses through a shared mechanism. `@fix` can do L2. **Since the last review** (on 8d516c85f4c6) Resolved: L1 (The compiler is detected before enabling C++ mode, so this checks CC rather than the CXX t…); L3 (The generated stand-ins omit the cloth_layout symbol required by the crate's tests.); L4 (The game-library guard relies on a marker set by only one of the ways to build the Rust li…) Still open: L2 (The interlocked store does not make the interpreter's ordinary accesses to interrupt_count…) <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes. The author reports that Windows dev.py rt and smoke passed, and that a Windows from-source build completed in 349 seconds; the corresponding builds previously stopped at the described failures. This is not a game performance change. **Other systems:** The changes affect Windows developer builds, Windows from-source builds, and MSVC-hosted crate builds. The author reports Windows game and build checks; Linux builds and other compiler combinations are not evidenced by a new run. **Switches:** LONGSHOT_GAME_RUST is added as an internal build marker, absent by default and set by the developer game Rust build; it rejects cloth stand-ins for that build. **Reviewed:** 2927672de36c against e132adfa0cf1: Read the repository rules and pull request template, the cloth build script, script build script, atomic shim, game-library build script, and the relevant diffs and watchdog references. The remaining changed files and their surrounding code were skimmed rather than read in full; Tooling's separate repository rules were unavailable.; nothing run (a code review). **Checked and fine:** - The game-library MSVC target guard covers direct cargo builds. - The reported Windows run exercised both the developer runtime and from-source build. **Testing:** No commands that build or run the project were executed. The author reports Windows game, build and crate checks; the supplied CI has no head-only failures. **Overlaps and merge order:** The description identifies #2963 as the separate tool archive and pin needed for the complete Windows from-source toolchain. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.</sub>
Author
Contributor

About L2, which I'm leaving as it is, on purpose:

  • It is not new to Windows. The same race is on the GCC and clang path today: longshot_qjs_poll_soon stores the counter with a relaxed __atomic_store_n, and QuickJS decrements and resets it as a plain int (quickjs.c, js_poll_interrupts). longshot_quickjs.c's own comment already accepts it: a store that lands inside the decrement is lost, so the watchdog stores again at each of its ticks until the handler has answered, and the handler decides by the call's deadline. The shim only gives cl the same store, so Windows behaves as Linux and the release do.
  • Fixing it means changing QuickJS. Making every access atomic means changing interrupt_counter in upstream's quickjs.c (its type, or each access to it). This pull request leaves third_party/ untouched; a change to the vendored interpreter belongs in a pull request of its own, for every compiler at once.

If you want the counter made atomic in QuickJS, I can open that as a separate pull request.

About L2, which I'm leaving as it is, on purpose: - **It is not new to Windows.** The same race is on the GCC and clang path today: `longshot_qjs_poll_soon` stores the counter with a relaxed `__atomic_store_n`, and QuickJS decrements and resets it as a plain `int` (`quickjs.c`, `js_poll_interrupts`). `longshot_quickjs.c`'s own comment already accepts it: a store that lands inside the decrement is lost, so the watchdog stores again at each of its ticks until the handler has answered, and the handler decides by the call's deadline. The shim only gives `cl` the same store, so Windows behaves as Linux and the release do. - **Fixing it means changing QuickJS.** Making every access atomic means changing `interrupt_counter` in upstream's `quickjs.c` (its type, or each access to it). This pull request leaves `third_party/` untouched; a change to the vendored interpreter belongs in a pull request of its own, for every compiler at once. If you want the counter made atomic in QuickJS, I can open that as a separate pull request.
Owner

Closing this: we're doing this work in our own build and tool cleanup for mod-api, which covers each of the problems listed here. Thank you: your analysis and Windows runs shaped it. Your three test fixes are taken as they are, with a Co-authored-by for you.

It isn't on mod-api yet. It still has to pass its checks, and it hasn't run on Windows. A re-run of your Windows tests on it would help once it lands.

🤖 Generated with Claude Code

Closing this: we're doing this work in our own build and tool cleanup for `mod-api`, which covers each of the problems listed here. Thank you: your analysis and Windows runs shaped it. Your three test fixes are taken as they are, with a `Co-authored-by` for you. It isn't on `mod-api` yet. It still has to pass its checks, and it hasn't run on Windows. A re-run of your Windows tests on it would help once it lands. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
HumanBean closed this pull request 2026-12-02 18:20:17 +00:00
All checks were successful
PR description / Title and description (pull_request_target) Successful in 6s

Pull request closed

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

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2961
No description provided.