fix(builder): renhdrum.py and longshot_builder.py build pass rustc's and cc's flags whole, so a path with a space builds #2732

Merged
HumanBean merged 2 commits from llun/Longshot:fix/scripts-rustflags-path-with-space into main 2026-11-28 19:07:39 +00:00
Member

Summary

The two Python scripts that build Longshot's Rust for CI and developers can't build when a path they use has a space
in it. That covers a checkout, a --cache or --work folder, or a --sysroot under a folder like
C:\Portable Programs\…. Cargo stops at its first rustc call with rustc's
error: --remap-path-prefix must contain '=' between FROM and TO. This is the same bug
MagicBeanDev/Longshot#2731 fixes in the player-facing
builder's from_source/. These scripts are its Python twins, left out of that pull request to keep it to one topic.

How to see it on main: python -I scripts/renhdrum.py build --cache "<a folder with a space>/cache", or
python -I scripts/longshot_builder.py build from a checkout in such a folder.

The cause: renhdrum.py build and longshot_builder.py build put rustc's flags in RUSTFLAGS, which cargo splits
at every space and reads no quotes in. renhdrum.py also put libopus's -ffile-prefix-map=<work>=renhdrum in
CFLAGS_<target>, which the cc crate splits the same way.

The fix, as in #2731:

  • rustc's flags are a list, passed in CARGO_ENCODED_RUSTFLAGS (joined by \x1f, each flag whole). The PC's own
    RUSTFLAGS is dropped, where before its CARGO_ENCODED_RUSTFLAGS was. The flags are the same as before.
  • The C flag goes through the new renhdrum.prefix_map_cflags. When the work folder has whitespace, the flag is
    shell-quoted and CC_SHELL_ESCAPED_FLAGS=1 is set (RenHDrum's Cargo.lock pins cc 1.11.2, which reads it).
    Otherwise it is passed as before. The PC's own CC_SHELL_ESCAPED_FLAGS is dropped, so it can't make cc shell-split
    an unquoted Windows path, whose backslashes a shell split would eat.

Read first: cmd_build in scripts/renhdrum.py and prefix_map_cflags beside it, then cmd_build in
scripts/longshot_builder.py. longshot_builder.py game-rust already used CARGO_ENCODED_RUSTFLAGS for its one flag.
packager's RUSTFLAGS holds no path, so it is left as it is.

Testing

Tested: Windows 11, through the job queue (--mode build). This changes how two CI and developer scripts call
cargo, not anything the game runs: the flags are the same, and the builder came out byte-identical (below). Main's tree and this
branch's were each unpacked into a folder named Portable Programs (x), then built with their own scripts.

  • longshot_builder.py build --target windows --profile release, with --cache and --work in that folder and the
    checkout there too:
    • main fails at cargo's first rustc call: error: --remap-path-prefix must contain '=' between FROM and TO.
    • This branch compiles all 304 crates in 1 min 36 s. The program passes the script's own check, and
      longshot-builder.exe --version runs.
  • renhdrum.py build --target windows in that folder:
    • main fails the same way, in cargo's target probe.
    • This branch gets past it and runs RenHDrum's build.rs, which shows cc reading
      CFLAGS_x86_64_pc_windows_gnullvm = '-ffile-prefix-map=…\Portable Programs (x)\cache-renhdrum-work=renhdrum'
      with CC_SHELL_ESCAPED_FLAGS = 1. Then it stops, as it does on main in any folder: this PC's llvm-mingw has no
      llvm-ar. So libopus's C was not compiled here (see Still to test).
  • The flags are unchanged: main's tree and this branch's, built one after the other in the same folder without a
    space, gave byte-identical programs (sha256 11e27c36…c73c026). On the second build cargo recompiled only the
    Slint chain (i-slint-compiler, slint-build, slint-macros, slint, ui, longshot-builder), because the
    re-unpacked .slint files had new times. If rustc's flags had changed, cargo would have rebuilt every crate.
  • The checks:
    • tests/test_renhdrum.py and the new tests/test_longshot_builder.py read the flags the way cargo reads them
      (CARGO_ENCODED_RUSTFLAGS split at \x1f, else RUSTFLAGS split at spaces). They read CFLAGS_<target> the
      way cc reads it (shell-split with CC_SHELL_ESCAPED_FLAGS, else at spaces).
    • The new test_a_folder_with_a_space cases, for Windows and Linux in each file, fail on main (the test commit
      alone) because the remap is cut at the space. They pass here.
    • With the quoting in prefix_map_cflags undone, renhdrum's fails. With RUSTFLAGS put back, longshot_builder's
      fails.
    • test_the_pcs_own_flags_are_not_read (renhdrum) errors on main: the PC's CC_SHELL_ESCAPED_FLAGS makes cc
      shell-split an unquoted path with a quote in it.
    • The existing test_the_build and test_the_linux_build now check each flag whole, not as a substring of one
      string, and check the full -ffile-prefix-map=<work>=renhdrum, not only its prefix.
  • mise run test on Windows: 170 passed, 672 failed, 47 skipped. On main, on this PC: 170 passed, 671 failed. This
    PC has no C/C++ compiler or spirv-val on PATH, so those checks fail on both. The one extra failure here is
    tests/test_dev_ab.py, which passes on its own (twice, 35 tests) and reads nothing this changes; it failed only in
    the parallel run. test_renhdrum.py, test_longshot_builder.py, test_windows_on_linux.py, test_dev_packs.py
    and test_recomplauncher_json.py, the checks that read these scripts, pass.

Still to test:

  • Linux: python -I scripts/renhdrum.py build --cache "$HOME/Portable Programs/cache", expecting libopus's C to
    compile with the quoted flag and a renhdrum.so that passes check (by hand: this PC's WSL has no Python or ar)

Measurements

Nothing to measure: this changes how the same flags are passed to cargo and the cc crate, not what is compiled.

Risks

  • A cargo older than CARGO_ENCODED_RUSTFLAGS (1.55) would ignore the flags. Both scripts download their own pinned
    Rust, much newer than that.
  • A cc crate that doesn't know CC_SHELL_ESCAPED_FLAGS would get the quoted C flag with its quotes, only for a work
    folder with a space. RenHDrum pins cc 1.11.2, which knows it. On main that case fails outright.
  • Nothing changes for CI or the release: their paths have no space, and the flags are the same. A revert is enough.
    Nothing changes for a player.

Checklist

Ready for review

  • One topic, on current main; 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).
  • 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.
  • 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 The two Python scripts that build Longshot's Rust for CI and developers can't build when a path they use has a space in it. That covers a checkout, a `--cache` or `--work` folder, or a `--sysroot` under a folder like `C:\Portable Programs\…`. Cargo stops at its first rustc call with rustc's `error: --remap-path-prefix must contain '=' between FROM and TO`. This is the same bug [MagicBeanDev/Longshot#2731](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2731) fixes in the player-facing builder's `from_source/`. These scripts are its Python twins, left out of that pull request to keep it to one topic. **How to see it on main:** `python -I scripts/renhdrum.py build --cache "<a folder with a space>/cache"`, or `python -I scripts/longshot_builder.py build` from a checkout in such a folder. **The cause:** `renhdrum.py build` and `longshot_builder.py build` put rustc's flags in `RUSTFLAGS`, which cargo splits at every space and reads no quotes in. `renhdrum.py` also put libopus's `-ffile-prefix-map=<work>=renhdrum` in `CFLAGS_<target>`, which the cc crate splits the same way. **The fix**, as in #2731: - rustc's flags are a list, passed in `CARGO_ENCODED_RUSTFLAGS` (joined by `\x1f`, each flag whole). The PC's own `RUSTFLAGS` is dropped, where before its `CARGO_ENCODED_RUSTFLAGS` was. The flags are the same as before. - The C flag goes through the new `renhdrum.prefix_map_cflags`. When the work folder has whitespace, the flag is shell-quoted and `CC_SHELL_ESCAPED_FLAGS=1` is set (RenHDrum's Cargo.lock pins cc 1.11.2, which reads it). Otherwise it is passed as before. The PC's own `CC_SHELL_ESCAPED_FLAGS` is dropped, so it can't make cc shell-split an unquoted Windows path, whose backslashes a shell split would eat. Read first: `cmd_build` in `scripts/renhdrum.py` and `prefix_map_cflags` beside it, then `cmd_build` in `scripts/longshot_builder.py`. `longshot_builder.py game-rust` already used `CARGO_ENCODED_RUSTFLAGS` for its one flag. `packager`'s `RUSTFLAGS` holds no path, so it is left as it is. ## Testing **Tested:** Windows 11, through the job queue (`--mode build`). This changes how two CI and developer scripts call cargo, not anything the game runs: the flags are the same, and the builder came out byte-identical (below). Main's tree and this branch's were each unpacked into a folder named `Portable Programs (x)`, then built with their own scripts. - `longshot_builder.py build --target windows --profile release`, with `--cache` and `--work` in that folder and the checkout there too: - **main** fails at cargo's first rustc call: `error: --remap-path-prefix must contain '=' between FROM and TO`. - **This branch** compiles all 304 crates in 1 min 36 s. The program passes the script's own `check`, and `longshot-builder.exe --version` runs. - `renhdrum.py build --target windows` in that folder: - **main** fails the same way, in cargo's target probe. - **This branch** gets past it and runs RenHDrum's `build.rs`, which shows cc reading `CFLAGS_x86_64_pc_windows_gnullvm = '-ffile-prefix-map=…\Portable Programs (x)\cache-renhdrum-work=renhdrum'` with `CC_SHELL_ESCAPED_FLAGS = 1`. Then it stops, as it does on main in any folder: this PC's llvm-mingw has no `llvm-ar`. So libopus's C was not compiled here (see Still to test). - **The flags are unchanged:** main's tree and this branch's, built one after the other in the same folder without a space, gave byte-identical programs (sha256 `11e27c36…c73c026`). On the second build cargo recompiled only the Slint chain (`i-slint-compiler`, `slint-build`, `slint-macros`, `slint`, `ui`, `longshot-builder`), because the re-unpacked `.slint` files had new times. If rustc's flags had changed, cargo would have rebuilt every crate. - The checks: - `tests/test_renhdrum.py` and the new `tests/test_longshot_builder.py` read the flags the way cargo reads them (`CARGO_ENCODED_RUSTFLAGS` split at `\x1f`, else `RUSTFLAGS` split at spaces). They read `CFLAGS_<target>` the way cc reads it (shell-split with `CC_SHELL_ESCAPED_FLAGS`, else at spaces). - The new `test_a_folder_with_a_space` cases, for Windows and Linux in each file, fail on main (the test commit alone) because the remap is cut at the space. They pass here. - With the quoting in `prefix_map_cflags` undone, renhdrum's fails. With `RUSTFLAGS` put back, longshot_builder's fails. - `test_the_pcs_own_flags_are_not_read` (renhdrum) errors on main: the PC's `CC_SHELL_ESCAPED_FLAGS` makes cc shell-split an unquoted path with a quote in it. - The existing `test_the_build` and `test_the_linux_build` now check each flag whole, not as a substring of one string, and check the full `-ffile-prefix-map=<work>=renhdrum`, not only its prefix. - `mise run test` on Windows: 170 passed, 672 failed, 47 skipped. On main, on this PC: 170 passed, 671 failed. This PC has no C/C++ compiler or spirv-val on PATH, so those checks fail on both. The one extra failure here is `tests/test_dev_ab.py`, which passes on its own (twice, 35 tests) and reads nothing this changes; it failed only in the parallel run. `test_renhdrum.py`, `test_longshot_builder.py`, `test_windows_on_linux.py`, `test_dev_packs.py` and `test_recomplauncher_json.py`, the checks that read these scripts, pass. **Still to test:** - Linux: `python -I scripts/renhdrum.py build --cache "$HOME/Portable Programs/cache"`, expecting libopus's C to compile with the quoted flag and a renhdrum.so that passes `check` (by hand: this PC's WSL has no Python or `ar`) ## Measurements Nothing to measure: this changes how the same flags are passed to cargo and the cc crate, not what is compiled. ## Risks - A cargo older than `CARGO_ENCODED_RUSTFLAGS` (1.55) would ignore the flags. Both scripts download their own pinned Rust, much newer than that. - A cc crate that doesn't know `CC_SHELL_ESCAPED_FLAGS` would get the quoted C flag with its quotes, only for a work folder with a space. RenHDrum pins cc 1.11.2, which knows it. On main that case fails outright. - Nothing changes for CI or the release: their paths have no space, and the flags are the same. A revert is enough. Nothing changes for a player. ## Checklist ### Ready for review - [x] One topic, on current `main`; 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). - [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. - [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)
The flags are read as cargo reads them (CARGO_ENCODED_RUSTFLAGS whole between \x1f, else RUSTFLAGS split at every
space) and as the cc crate reads CFLAGS_<target> (shell-split with CC_SHELL_ESCAPED_FLAGS, else at every space). With
the cache, the work folder, the checkout or the sysroot in a folder with a space, each remap and the sysroot's link
flag must come through whole; the PC's own RUSTFLAGS, CARGO_ENCODED_RUSTFLAGS and CC_SHELL_ESCAPED_FLAGS change
nothing. Fails on main: the path is cut at its space.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(builder): renhdrum.py and longshot_builder.py build pass rustc's and cc's flags whole, so a path with a space builds
Some checks failed
CI / What the change needs (pull_request) Successful in 9s
CI / Third-party parts and guide screenshots (pull_request) Failing after 12s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 12s
PR description / Title and description (pull_request_target) Successful in 5s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 4m18s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 2m16s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 6m0s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 5m53s
CI / Website build and checks (pull_request) Failing after 34s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 27m57s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 40m28s
d7590d5d3a
Both scripts passed rustc's flags in RUSTFLAGS, which cargo splits at every space: a checkout, cache, work folder or
sysroot under a path with one (`C:\Portable Programs\...`) cut `--remap-path-prefix=<path>=<name>` in two, and rustc
stopped with "--remap-path-prefix must contain '=' between FROM and TO". The flags now go in CARGO_ENCODED_RUSTFLAGS,
each whole between \x1f, and the PC's RUSTFLAGS is dropped, as MagicBeanDev/Longshot#2731 does for the builder's
from-source.

RenHDrum's libopus flag `-ffile-prefix-map=<work>=renhdrum` had the same problem in the cc crate's CFLAGS_<target>:
when the work folder has whitespace it is now shell-quoted with CC_SHELL_ESCAPED_FLAGS=1 (cc 1.11.2, Cargo.lock's,
reads it); otherwise it is passed as before. The PC's own CC_SHELL_ESCAPED_FLAGS is dropped, so it can't make cc
shell-split an unquoted Windows path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
llun changed title from WIP: fix(builder): renhdrum.py and longshot_builder.py build pass rustc's and cc's flags whole, so a path with a space builds to fix(builder): renhdrum.py and longshot_builder.py build pass rustc's and cc's flags whole, so a path with a space builds 2026-11-28 10:22:12 +00:00
Author
Member
@review
BeanBot left a comment

Recommendation: Request changes. The RenHDrum C compilation needs a completed build on both Windows and Linux.

The scripts pass Rust flags as whole arguments and quote RenHDrum’s C flag when its work path has whitespace. This addresses the reported split, with a remaining path-escaping case.

Blocking (1): must change before merging.

  1. L1: The check CI / Third-party parts and guide screenshots (pull_request) fails on this head and passes on the base branch: Failing after 12s.

@fix can do L1.

Questions (1) (not confirmed from the code; they don't hold the recommendation)

  • Can RenHDrum be built through libopus compilation and its output check on Windows and Linux with a work path containing spaces? The reported Windows run stopped before C compilation.

Checks: Still running: 7 checks.

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

Does it help: Partly shown: the reported Windows longshot-builder build failed on main and completed on this branch. RenHDrum reached its build script but stopped before compiling libopus; Linux builds have not been reported.

Other systems: Both scripts run on Windows and Linux. The tests model Cargo and cc flag splitting but stub the actual compilation; the game and renderer are not changed.

Switches: No player switches added or changed. The scripts now set CARGO_ENCODED_RUSTFLAGS and remove inherited RUSTFLAGS; RenHDrum sets CC_SHELL_ESCAPED_FLAGS=1 only when its C flag contains whitespace and otherwise removes the inherited value.

Reviewed: d7590d5d3a against 22d0d20098: Read the repository rules, standards, PR template, commits, diff, changed scripts and tests, and relevant build and configuration paths. Rechecked each changed file. The separate review checklist and adjacent Tooling checkout were absent. CI logs and external crate source were not available.; nothing run (a code review).

Checked and fine:

  • Both commits record AI assistance.
  • No game-derived files, generated files, third-party changes or renderer API changes appear in the diff.
  • The reported Windows builder run and the flag tests cover the ordinary space-containing path case.
  • The failing head-only CI check is left to the bot’s CI item.

Testing: Read-only review; no tests or project scripts were run. The PR reports a successful Windows longshot-builder build and an incomplete Windows RenHDrum build.

Overlaps and merge order: The description identifies #2731 as the related player-facing builder fix; its merge state was not available offline.


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

**Recommendation: Request changes.** The RenHDrum C compilation needs a completed build on both Windows and Linux. The scripts pass Rust flags as whole arguments and quote RenHDrum’s C flag when its work path has whitespace. This addresses the reported split, with a remaining path-escaping case. **Blocking (1)**: must change before merging. 1. **L1**: The check `CI / Third-party parts and guide screenshots (pull_request)` fails on this head and passes on the base branch: Failing after 12s. `@fix` can do L1. **Questions (1)** (not confirmed from the code; they don't hold the recommendation) - Can RenHDrum be built through libopus compilation and its output check on Windows and Linux with a work path containing spaces? The reported Windows run stopped before C compilation. **Checks:** Still running: 7 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Partly shown: the reported Windows longshot-builder build failed on main and completed on this branch. RenHDrum reached its build script but stopped before compiling libopus; Linux builds have not been reported. **Other systems:** Both scripts run on Windows and Linux. The tests model Cargo and cc flag splitting but stub the actual compilation; the game and renderer are not changed. **Switches:** No player switches added or changed. The scripts now set CARGO_ENCODED_RUSTFLAGS and remove inherited RUSTFLAGS; RenHDrum sets CC_SHELL_ESCAPED_FLAGS=1 only when its C flag contains whitespace and otherwise removes the inherited value. **Reviewed:** d7590d5d3a8b against 22d0d20098d6: Read the repository rules, standards, PR template, commits, diff, changed scripts and tests, and relevant build and configuration paths. Rechecked each changed file. The separate review checklist and adjacent Tooling checkout were absent. CI logs and external crate source were not available.; nothing run (a code review). **Checked and fine:** - Both commits record AI assistance. - No game-derived files, generated files, third-party changes or renderer API changes appear in the diff. - The reported Windows builder run and the flag tests cover the ordinary space-containing path case. - The failing head-only CI check is left to the bot’s CI item. **Testing:** Read-only review; no tests or project scripts were run. The PR reports a successful Windows longshot-builder build and an incomplete Windows RenHDrum build. **Overlaps and merge order:** The description identifies #2731 as the related player-facing builder fix; its merge state was not available offline. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.</sub>
Author
Member
@fix
Member

Nothing needed changing: the review's items are already done.

Not done

  • Guide screenshot CI failure: The supplied log omits the 14 affected filenames. This branch changes no files recorded in the screenshot manifest, so the failure cannot be diagnosed from the available evidence. The full CI log is needed to identify and review the mismatched sources before changing their review records.

Nothing was pushed.


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

Nothing needed changing: the review's items are already done. **Not done** - **Guide screenshot CI failure**: The supplied log omits the 14 affected filenames. This branch changes no files recorded in the screenshot manifest, so the failure cannot be diagnosed from the available evidence. The full CI log is needed to identify and review the mismatched sources before changing their review records. Nothing was pushed. --- <sub>Automated fix by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.</sub>
HumanBean deleted branch fix/scripts-rustflags-path-with-space 2026-11-28 19:07:40 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 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!2732
No description provided.