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
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2732
Loading…
Reference in a new issue
No description provided.
Delete branch "llun/Longshot:fix/scripts-rustflags-path-with-space"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
--cacheor--workfolder, or a--sysrootunder a folder likeC:\Portable Programs\…. Cargo stops at its first rustc call with rustc'serror: --remap-path-prefix must contain '=' between FROM and TO. This is the same bugMagicBeanDev/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", orpython -I scripts/longshot_builder.py buildfrom a checkout in such a folder.The cause:
renhdrum.py buildandlongshot_builder.py buildput rustc's flags inRUSTFLAGS, which cargo splitsat every space and reads no quotes in.
renhdrum.pyalso put libopus's-ffile-prefix-map=<work>=renhdruminCFLAGS_<target>, which the cc crate splits the same way.The fix, as in #2731:
CARGO_ENCODED_RUSTFLAGS(joined by\x1f, each flag whole). The PC's ownRUSTFLAGSis dropped, where before itsCARGO_ENCODED_RUSTFLAGSwas. The flags are the same as before.renhdrum.prefix_map_cflags. When the work folder has whitespace, the flag isshell-quoted and
CC_SHELL_ESCAPED_FLAGS=1is 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_FLAGSis dropped, so it can't make cc shell-splitan unquoted Windows path, whose backslashes a shell split would eat.
Read first:
cmd_buildinscripts/renhdrum.pyandprefix_map_cflagsbeside it, thencmd_buildinscripts/longshot_builder.py.longshot_builder.py game-rustalready usedCARGO_ENCODED_RUSTFLAGSfor its one flag.packager'sRUSTFLAGSholds 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 callcargo, 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--cacheand--workin that folder and thecheckout there too:
error: --remap-path-prefix must contain '=' between FROM and TO.check, andlongshot-builder.exe --versionruns.renhdrum.py build --target windowsin that folder:build.rs, which shows cc readingCFLAGS_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 nollvm-ar. So libopus's C was not compiled here (see Still to test).space, gave byte-identical programs (sha256
11e27c36…c73c026). On the second build cargo recompiled only theSlint chain (
i-slint-compiler,slint-build,slint-macros,slint,ui,longshot-builder), because there-unpacked
.slintfiles had new times. If rustc's flags had changed, cargo would have rebuilt every crate.tests/test_renhdrum.pyand the newtests/test_longshot_builder.pyread the flags the way cargo reads them(
CARGO_ENCODED_RUSTFLAGSsplit at\x1f, elseRUSTFLAGSsplit at spaces). They readCFLAGS_<target>theway cc reads it (shell-split with
CC_SHELL_ESCAPED_FLAGS, else at spaces).test_a_folder_with_a_spacecases, for Windows and Linux in each file, fail on main (the test commitalone) because the remap is cut at the space. They pass here.
prefix_map_cflagsundone, renhdrum's fails. WithRUSTFLAGSput back, longshot_builder'sfails.
test_the_pcs_own_flags_are_not_read(renhdrum) errors on main: the PC'sCC_SHELL_ESCAPED_FLAGSmakes ccshell-split an unquoted path with a quote in it.
test_the_buildandtest_the_linux_buildnow check each flag whole, not as a substring of onestring, and check the full
-ffile-prefix-map=<work>=renhdrum, not only its prefix.mise run teston Windows: 170 passed, 672 failed, 47 skipped. On main, on this PC: 170 passed, 671 failed. ThisPC 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 inthe parallel run.
test_renhdrum.py,test_longshot_builder.py,test_windows_on_linux.py,test_dev_packs.pyand
test_recomplauncher_json.py, the checks that read these scripts, pass.Still to test:
python -I scripts/renhdrum.py build --cache "$HOME/Portable Programs/cache", expecting libopus's C tocompile with the quoted flag and a renhdrum.so that passes
check(by hand: this PC's WSL has no Python orar)Measurements
Nothing to measure: this changes how the same flags are passed to cargo and the cc crate, not what is compiled.
Risks
CARGO_ENCODED_RUSTFLAGS(1.55) would ignore the flags. Both scripts download their own pinnedRust, much newer than that.
CC_SHELL_ESCAPED_FLAGSwould get the quoted C flag with its quotes, only for a workfolder with a space. RenHDrum pins cc 1.11.2, which knows it. On main that case fails outright.
Nothing changes for a player.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
WIP: fix(builder): renhdrum.py and longshot_builder.py build pass rustc's and cc's flags whole, so a path with a space buildsto fix(builder): renhdrum.py and longshot_builder.py build pass rustc's and cc's flags whole, so a path with a space builds@review
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.
CI / Third-party parts and guide screenshots (pull_request)fails on this head and passes on the base branch: Failing after 12s.@fixcan do L1.Questions (1) (not confirmed from the code; they don't hold the recommendation)
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:
d7590d5d3aagainst22d0d20098: 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:
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.
@fix
Nothing needed changing: the review's items are already done.
Not done
Nothing was pushed.
Automated fix by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
dev compile, and a failure there says what the builder said #2774