WIP: fix(builder): Windows: an unchanged link is not run again: a drive's colon is no option's separator #2835

Draft
llun wants to merge 2 commits from llun/Longshot:fix/mod-api-win-relink into mod-api
Member

Summary

For #2822 (into mod-api). On Windows, every build links the game and the renderer again, even when nothing changed. link::run (builder/crates/build-compile/src/link.rs) skips a link whose inputs, outputs and key are as the last link left them. Its key comes from link_inputs, which also looks for a file named inside an option, after the option's first : or = (/map:<file>, --symbol-ordering-file=<file>). A whole Windows path's drive was taken for such a separator: -o C:\…\longshot-game.exe gave \…\longshot-game.exe. That's the last link's own output under another name, so it went into the key, the key changed at every link, and no link was ever found unchanged. This makes option_value take the first =, or a : that is not a drive's (a letter alone before it, a separator after it). /map:C:/x still gives C:/x. Linux's paths hold no drive, so Linux is unchanged.

To see it on mod-api: Windows, dev.py pack twice with nothing changed. The second still says linked …longshot-game.exe: 911 MB and linked …longshot_vk.dll.

Read first: option_value and link_inputs in builder/crates/build-compile/src/link.rs.

Testing

Tested: Windows 11, RTX 5080, NVIDIA 621.40.

  • Real builds: mise run dev -- pack --own-work twice in a row on the PC's shared base, the second with 0 of 884 units to compile. With mod-api's builder the second pack linked the game (911 MB, 5 s) and the renderer (1 s) again. With this branch's builder it said not linked again for longshot-game.exe, longshot_vk.dll and longshot_nvngx.dll_nr.dll.
  • In the game: a builder from this branch (with #2726's broker change applied locally beneath it) started the game confined through longshot-builder game with a profile: the AppContainer, the builder's channel, Skip title screen and the profile's mods started, and it played until the run's time limit.

Checks:

  • The new link::tests::the_output_is_not_an_input_whatever_its_path_holds fails on mod-api @ eaf4a48b on Windows (the output among the inputs as \Users\…\x.exe) and passes here.
  • tests/compile_link.rs's program is now prog.exe on Windows, the file the link writes. It used to link prog, so link::run never found its output. an_unchanged_rebuild_compiles_nothing_and_a_change_compiles_what_it_touches then fails on mod-api on Windows ("and links nothing") and passes here: 4 of 4.
  • The new an_options_value_is_after_its_separator_never_a_drives_colon checks the separator's cases on every OS.
  • On Linux (WSL Ubuntu 24.04, its clang and ld.lld) cargo test -p build-compile --lib --test compile_link passes: 67 and 4. On Windows all build-compile lib tests pass but toolchain's, which fails on mod-api too and which #2834 fixes.
  • cargo fmt --check and mise run lint pass. cargo clippy -p build-compile --all-targets --no-deps -- -D warnings (Windows target) reports only mod-api's own builds error, which #2830 fixes.

Still to test:

  • Linux: two dev.py pack in a row with nothing changed, expecting not linked again for the game as before (@Beanstalk: an unchanged rebuild on Linux links nothing)

Measurements

Verdict: an unchanged build on Windows links nothing. It took 6 s instead of 12 s here, the game's 911 MB link not made.

Baseline: mod-api (#2822's head), the branch this PR goes into: the bug is there, not on main.

Setup: Windows 11, Ryzen 9 9900X3D, RTX 5080, the PC's shared base 3ab4db6e, mise run dev -- pack --own-work of the same tree twice in a row with each builder. The second pack's lines and its total, one run each: a link is either made or not, and the time is the build's own report.

The second (unchanged) pack Before: mod-api @ eaf4a48b After: this PR @ 328cfce6
longshot-game.exe linked again, 911 MB, 5 s not linked again
longshot_vk.dll linked again, 14 MB, 1 s not linked again
The build's total (its compile phase) 12 s (7 s) 6 s (2 s)
link::tests::the_output_is_not_an_input_whatever_its_path_holds, Windows FAIL pass
compile_link's an_unchanged_rebuild_…, Windows FAIL pass

Risks

The sandbox: not touched. This is the builder's link step on the developer's or player's PC, before any game runs. The game it builds is confined as before.

A link is skipped only when its key, linker, outputs and the files it read all match the last link's, as before; the key just no longer holds the output itself. A file named inside an option after a drive's colon (none of the builder's commands has one) is no longer taken as an input. A revert is enough. Players on Windows see a rebuild with nothing to compile finish sooner.

Checklist

Ready for review

  • One topic, on current mod-api (#2822's head); 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 checks this change reaches pass, apart from toolchain's on Windows, which fails on mod-api too, as above. mod-api's whole suite has other failures on Windows that this PR doesn't change.)
  • 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. (It fails on mod-api, where the bug is.)
  • A check under tests/ that reads changed source is updated, not weakened.
  • 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 [#2822](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2822) (into `mod-api`). On Windows, every build links the game and the renderer again, even when nothing changed. `link::run` (`builder/crates/build-compile/src/link.rs`) skips a link whose inputs, outputs and key are as the last link left them. Its key comes from `link_inputs`, which also looks for a file named inside an option, after the option's first `:` or `=` (`/map:<file>`, `--symbol-ordering-file=<file>`). A whole Windows path's drive was taken for such a separator: `-o C:\…\longshot-game.exe` gave `\…\longshot-game.exe`. That's the last link's own output under another name, so it went into the key, the key changed at every link, and no link was ever found unchanged. This makes `option_value` take the first `=`, or a `:` that is not a drive's (a letter alone before it, a separator after it). `/map:C:/x` still gives `C:/x`. Linux's paths hold no drive, so Linux is unchanged. **To see it on `mod-api`:** Windows, `dev.py pack` twice with nothing changed. The second still says `linked …longshot-game.exe: 911 MB` and `linked …longshot_vk.dll`. Read first: `option_value` and `link_inputs` in `builder/crates/build-compile/src/link.rs`. ## Testing **Tested:** Windows 11, RTX 5080, NVIDIA 621.40. - **Real builds:** `mise run dev -- pack --own-work` twice in a row on the PC's shared base, the second with 0 of 884 units to compile. With `mod-api`'s builder the second pack linked the game (911 MB, 5 s) and the renderer (1 s) again. With this branch's builder it said `not linked again` for `longshot-game.exe`, `longshot_vk.dll` and `longshot_nvngx.dll_nr.dll`. - **In the game:** a builder from this branch (with [#2726](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2726)'s broker change applied locally beneath it) started the game confined through `longshot-builder game` with a profile: the AppContainer, the builder's channel, Skip title screen and the profile's mods started, and it played until the run's time limit. Checks: - The new `link::tests::the_output_is_not_an_input_whatever_its_path_holds` fails on `mod-api` @ eaf4a48b on Windows (the output among the inputs as `\Users\…\x.exe`) and passes here. - `tests/compile_link.rs`'s program is now `prog.exe` on Windows, the file the link writes. It used to link `prog`, so `link::run` never found its output. `an_unchanged_rebuild_compiles_nothing_and_a_change_compiles_what_it_touches` then fails on `mod-api` on Windows ("and links nothing") and passes here: 4 of 4. - The new `an_options_value_is_after_its_separator_never_a_drives_colon` checks the separator's cases on every OS. - On Linux (WSL Ubuntu 24.04, its clang and ld.lld) `cargo test -p build-compile --lib --test compile_link` passes: 67 and 4. On Windows all `build-compile` lib tests pass but `toolchain`'s, which fails on `mod-api` too and which [#2834](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2834) fixes. - `cargo fmt --check` and `mise run lint` pass. `cargo clippy -p build-compile --all-targets --no-deps -- -D warnings` (Windows target) reports only `mod-api`'s own `builds` error, which [#2830](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2830) fixes. **Still to test:** - Linux: two `dev.py pack` in a row with nothing changed, expecting `not linked again` for the game as before (@Beanstalk: an unchanged rebuild on Linux links nothing) ## Measurements **Verdict:** an unchanged build on Windows links nothing. It took 6 s instead of 12 s here, the game's 911 MB link not made. Baseline: `mod-api` (#2822's head), the branch this PR goes into: the bug is there, not on `main`. Setup: Windows 11, Ryzen 9 9900X3D, RTX 5080, the PC's shared base 3ab4db6e, `mise run dev -- pack --own-work` of the same tree twice in a row with each builder. The second pack's lines and its total, one run each: a link is either made or not, and the time is the build's own report. | The second (unchanged) pack | Before: mod-api @ eaf4a48b | After: this PR @ 328cfce6 | |---|---|---| | `longshot-game.exe` | linked again, 911 MB, 5 s | not linked again | | `longshot_vk.dll` | linked again, 14 MB, 1 s | not linked again | | The build's total (its compile phase) | 12 s (7 s) | 6 s (2 s) | | `link::tests::the_output_is_not_an_input_whatever_its_path_holds`, Windows | FAIL | pass | | `compile_link`'s `an_unchanged_rebuild_…`, Windows | FAIL | pass | ## Risks **The sandbox:** not touched. This is the builder's link step on the developer's or player's PC, before any game runs. The game it builds is confined as before. A link is skipped only when its key, linker, outputs and the files it read all match the last link's, as before; the key just no longer holds the output itself. A file named inside an option after a drive's colon (none of the builder's commands has one) is no longer taken as an input. A revert is enough. Players on Windows see a rebuild with nothing to compile finish sooner. ## Checklist ### Ready for review - [x] One topic, on current `mod-api` (#2822's head); the title is a Conventional Commit. - [x] 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 checks this change reaches pass, apart from `toolchain`'s on Windows, which fails on `mod-api` too, as above. `mod-api`'s whole suite has other failures on Windows that this PR doesn't change.) - [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. (It fails on `mod-api`, where the bug is.) - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] 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](https://claude.com/claude-code)
link::tests::the_output_is_not_an_input_whatever_its_path_holds: a link whose output exists (the last link's) and an
ordering file inside an option; the inputs must be the ordering file alone. It fails on mod-api on Windows: link_inputs
looks for a file after an argument's first ':' or '=', and a whole path's drive (C:/w/x.exe) gives /w/x.exe, the
output itself under another name, which then is in the link's key and changes it at each link.

tests/compile_link.rs's program is prog.exe on Windows, the file the link writes (it linked prog, and link::run
looked for prog): an_unchanged_rebuild_compiles_nothing_and_a_change_compiles_what_it_touches then fails on Windows
for the same reason ("and links nothing").

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(builder): Windows: an unchanged link is not run again: a drive's colon is no option's separator
All checks were successful
PR description / Title and description (pull_request_target) Successful in 13s
2007ad2473
link_inputs looks for a file inside an option, after its first ':' or '='. A whole Windows path's drive was taken for
one: `-o C:\...\longshot-game.exe` gave `\...\longshot-game.exe`, the last link's output under another name, which
went into the link's key, so the key changed at each link and every link ran again: an unchanged pack still linked
the game (911 MB, 5 s) and the renderer. option_value now takes the first '=' or a ':' that is not a drive's (a
letter alone before it, a separator after it): `/map:C:/x` still gives `C:/x`. Linux's paths hold no drive: unchanged.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

Tested in the game: Windows 11, RTX 5080, NVIDIA 621.40: a builder built from this branch (with #2726's broker change applied locally beneath it) started the game confined through longshot-builder game with a profile: the AppContainer, mods: the builder's channel is open (31 ops), Skip title screen and the profile's mods started, and it played until the run's time limit. Its builds: an unchanged dev.py pack says not linked again for longshot-game.exe and longshot_vk.dll (mod-api's builder linked both again).

Tested in the game: Windows 11, RTX 5080, NVIDIA 621.40: a builder built from this branch (with #2726's broker change applied locally beneath it) started the game confined through `longshot-builder game` with a profile: the AppContainer, `mods: the builder's channel is open (31 ops)`, Skip title screen and the profile's mods started, and it played until the run's time limit. Its builds: an unchanged `dev.py pack` says `not linked again` for longshot-game.exe and longshot_vk.dll (mod-api's builder linked both again).
Author
Member

Risks now says how this change stands with the sandbox (what it touches, and why the confined game reaches nothing more).

Risks now says how this change stands with the sandbox (what it touches, and why the confined game reaches nothing more).
llun force-pushed fix/mod-api-win-relink from 2007ad2473
All checks were successful
PR description / Title and description (pull_request_target) Successful in 13s
to dc9c50f1b4
All checks were successful
PR description / Title and description (pull_request_target) Successful in 13s
2026-11-29 23:27:51 +00:00
Compare
Author
Member

Rebased onto mod-api's newest (4cc50ca1: main's newest merged in), with no conflict; this PR's own checks were run again on the rebased head and pass as before. The merge touched none of this PR's files (#2827: only a comment in host/hos_main.c, far from its change), so the measurements and runs above hold; the After commit is the rebased head.

Rebased onto mod-api's newest (4cc50ca1: main's newest merged in), with no conflict; this PR's own checks were run again on the rebased head and pass as before. The merge touched none of this PR's files (#2827: only a comment in host/hos_main.c, far from its change), so the measurements and runs above hold; the After commit is the rebased head.
llun force-pushed fix/mod-api-win-relink from dc9c50f1b4
All checks were successful
PR description / Title and description (pull_request_target) Successful in 13s
to b8d070bb6f
All checks were successful
PR description / Title and description (pull_request_target) Successful in 9s
2026-11-29 23:58:45 +00:00
Compare
Author
Member

Rebased onto mod-api @ 816d2354 (#2837, headless shots of the mods' UI), now b8d070bb. No conflict, and the diff is the same as before (same git patch-id). #2837 touches none of this PR's files.

Rebased onto `mod-api` @ 816d2354 ([#2837](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2837), headless shots of the mods' UI), now b8d070bb. No conflict, and the diff is the same as before (same `git patch-id`). #2837 touches none of this PR's files.
llun force-pushed fix/mod-api-win-relink from b8d070bb6f
All checks were successful
PR description / Title and description (pull_request_target) Successful in 9s
to 356ff56a95
All checks were successful
PR description / Title and description (pull_request_target) Successful in 56s
2026-11-30 00:39:28 +00:00
Compare
llun force-pushed fix/mod-api-win-relink from 356ff56a95
All checks were successful
PR description / Title and description (pull_request_target) Successful in 56s
to 328cfce6d8
All checks were successful
PR description / Title and description (pull_request_target) Successful in 15s
2026-11-30 00:43:18 +00:00
Compare
Author
Member

Rebased onto mod-api @ c5e5b676: it was re-squashed onto main @ 46291934 (#2833) twice today (cdbb8551, then c5e5b676), which made this PR show main's and the whole mod API's diff. Now 328cfce6, the same diff as before (same git patch-id), no conflict. The changes underneath touch none of this PR's files, so its checks still hold.

Rebased onto `mod-api` @ c5e5b676: it was re-squashed onto main @ 46291934 (#2833) twice today (cdbb8551, then c5e5b676), which made this PR show main's and the whole mod API's diff. Now 328cfce6, the same diff as before (same `git patch-id`), no conflict. The changes underneath touch none of this PR's files, so its checks still hold.
All checks were successful
PR description / Title and description (pull_request_target) Successful in 15s
This pull request is marked as a work in progress.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/mod-api-win-relink:llun-fix/mod-api-win-relink'
git switch 'llun-fix/mod-api-win-relink'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'mod-api'
git merge --no-ff 'llun-fix/mod-api-win-relink'
git switch 'llun-fix/mod-api-win-relink'
git rebase 'mod-api'
git switch 'mod-api'
git merge --ff-only 'llun-fix/mod-api-win-relink'
git switch 'llun-fix/mod-api-win-relink'
git rebase 'mod-api'
git switch 'mod-api'
git merge --no-ff 'llun-fix/mod-api-win-relink'
git switch 'mod-api'
git merge --squash 'llun-fix/mod-api-win-relink'
git switch 'mod-api'
git merge --ff-only 'llun-fix/mod-api-win-relink'
git switch 'mod-api'
git merge 'llun-fix/mod-api-win-relink'
git push origin 'mod-api'
Sign in to join this conversation.
No reviewers
No milestone
No project
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.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2835
No description provided.