fix(builder): from-source passes rustc's flags whole, so a data folder with a space in its path builds #2731
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2731
Loading…
Reference in a new issue
No description provided.
Delete branch "llun/Longshot:fix/from-source-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
A player whose launcher data folder is in a path with a space (for example under
C:\Portable Programs\…) can't build any pull request. The launcher stops at "The source's longshot-builder did not compile from this source (exit code: 101)", and cargo's output ends with rustc'serror: --remap-path-prefix must contain '=' between FROM and TO.How to see it on main: run the nightly's
longshot-builder from-source --commit <a PR's head> --out <folder> --cache "<a folder with a space>", which is what the launcher runs for a pull request. Cargo's first rustc call fails with the error above.The cause:
from-sourcepassed rustc's flags to cargo inRUSTFLAGS, and cargo splits that variable at every space. So--remap-path-prefix=C:\Portable Programs\…\src=longshotreached rustc as--remap-path-prefix=C:\PortableandPrograms\…=longshot. Quoting can't help, because cargo doesn't read quotes inRUSTFLAGS.The fix: the flags now go in
CARGO_ENCODED_RUSTFLAGS, which keeps each flag whole (they are separated by\x1f, not spaces).release_flagsreturns a list, andToolchain::commandandcargo::buildtake one. RenHDrum's flags go the same way. The game's Rust archive already usedCARGO_ENCODED_RUSTFLAGSfor its one flag; it now goes through the same parameter and gets the same flag as before. RenHDrum's C flag-ffile-prefix-map=<work>=renhdrumhad the same problem: the cc crate also splitsCFLAGSat spaces. When its folder has a space, it is now shell-quoted andCC_SHELL_ESCAPED_FLAGS=1is set. Otherwise it is passed as before, so a source whose cc is older than that switch still builds as it did. The cc crate takesCC_<target>andAR_<target>as they are when they name an existing file, so those were already fine.Read first:
release_flags,remap,target_flags,prefix_map_cflagsandToolchain::commandinbuilder/crates/longshot-builder/src/from_source/cargo.rs, then the two call sites infrom_source/mod.rs(renhdrum,build_game_rust).The fix reaches players with the next nightly after merge: the launcher runs the newest nightly's builder for
from-source. Until then, a player can choose a work folder in a path without spaces under Data and cache folders.Testing
Tested: Windows 11, RTX 5080, NVIDIA 621.40. This changes how the builder compiles a pull request's builder from source, not the game. So the game run below is the launcher's whole path for a pull request in a folder with a space: from-source, then that builder builds the game, then the game plays.
the_release_s_flags_hold_in_a_folder_with_a_space_in_its_name(new, infrom_source/cargo.rs). It runs a realcargo buildof a library with no dependencies in a folder namedPortable Programs & (Jane's) ünï, usingrelease_flagsandToolchain::commandand the cargo that runs the test. It also checks that the library names no path of that folder, which shows the remap held.--remap-path-prefix must contain '=' between FROM and TO, the player's error.remapbroken on purpose, it fails with "the library names the folder", so both halves of the check work.the_release_s_flags_name_no_path_of_this_pcnow builds its expected paths the way this system joins them. On main it failed on Windows, because it expected/c/fs/src/builderwhere Windows joins/c/fs/src\builder.from-source --commit 0b701b22dcf0b1f963785f4068faf4c7b44a3ef2(MagicBeanDev/Longshot#2728's head, the pull request the player was building), with--cacheand--outin a folder namedPortable Programs & (Jane) ünï, run through the job queue. That is what the launcher runs.error: --remap-path-prefix must contain '=' between FROM and TO, the player's error.longshot-builderin 89 s and writes the version folder, 119 s in all. ItsLongshot.exe --versionsayslongshot-builder pr-2728-0b701b22.pr-2728-0b701b22builder ranbuild --profile <folder>\profile --game <the .nup> --upscaler none --no-prepare-shaders(withLONGSHOT_CACHEin that folder). It built the game in 3:04 intoversions\pr-2728-0b701b22\builds\default. Thenplay --profile …through the job queue (Windows 11, RTX 5080, NVIDIA 621.40). The game prepared its 38,192 pipelines into that folder's shader store at first start, then booted, writing its saves into the profile. I stopped it there.renhdrum_not_built, the usual case on Windows).from-sourceof #2728, in a folder with a space in its path, with anllvm-arfrom a full llvm-mingw (LLVM 23.1.5) on PATH, sofrom-sourcecompiles RenHDrum.renhdrum.dllin 20 s with the quotedCFLAGS_x86_64_pc_windows_gnullvmandCC_SHELL_ESCAPED_FLAGS=1. It then packs it (31 members), compiles the pull request's builder and writes the version folder (245 s). That builder's--versionreads its pack.prefix_map_cflagsalways plain) fails in RenHDrum's build script. cc splits the flag, and clang reportsno such file or directory: 'ünï\…\renhdrum\work=renhdrum'. So the quoting is what makes it compile.(Jane's)). That run got through everything up to the builder's compile, then a build script's link failed, because clang got the Rust library paths with the'dropped. The likely cause is the argument file rustc writes for a GNU-style linker, which escapes spaces and backslashes but not'. That is in rustc and llvm-mingw's clang, not in these flags. A data folder under a Windows user name with an apostrophe would hit it.cargo test --locked -p longshot-builder --bin longshot-builder: everyfrom_sourcetest passes. 7 other tests fail on this Windows PC, and the same 7 fail on main (steam_cmd,dev::site_hooks,doctor,play, and 3 inmain.rs; none in files this touches).cargo clippy -p longshot-builder -- -D warningshas 2 errors, inafter.rs:398andplay.rs:644(unused ExitCode), which also fail on main with this PC's Rust 1.100. CI's pinned toolchain decides.bd7bcb52, which includes #2724 and #2732. Main's commits since22d0d200change nothing underfrom_source/or inbuild.md, so the runs above still hold. After the rebase, the test commit alone still fails with rustc's--remap-path-prefix must contain '=', and the 17from_sourcetests pass on the head.tests/reads the changed files.pr status's hint matchestests/test_dev_ab.py'stest_wired_from_source, which testsdev.py ab's switch scan (ab.wired_switches()) and has "from_source" only in its name. So the box for it doesn't apply and is left out.scripts/check_guide_screenshots.py --review-sources(CI's "Third-party parts and guide screenshots"): the 14 issues main had are gone with #2724. One remains on main atbd7bcb52itself, byte-identical on this branch:settings-graphics.png: gpu/vk/device_policy.h changed since reviewed revision b31dccae, from #2730. This branch doesn't touch that file.cargo test --workspaceruns the new test on Linux.mise run test: 169 passed, 672 failed, 47 skipped. The same 672 fail on main on this PC, which has no C/C++ compiler or glslang on PATH; the failing lists are identical.Still to test:
from-sourcewith--cachein a folder with a space compiles RenHDrum and then the builder, expecting no cc error (by hand). The same cc path was compiled for real on Windows (Tested).Measurements
Nothing to measure: this changes how flags are passed to cargo and the cc crate, not what is compiled. The flags are the same.
Risks
CARGO_ENCODED_RUSTFLAGS(cargo 1.55) would ignore the flags. Every source pins a much newer Rust.CC_SHELL_ESCAPED_FLAGS, built in a folder with a space, would get RenHDrum's-ffile-prefix-mapwith literal quotes. Its C would then still compile, without that remap. On main that case fails outright.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.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
The flags of from-source's cargo runs went in RUSTFLAGS, which cargo splits at every space: with the launcher's data folder in a path with a space, each --remap-path-prefix=<path>=<name> was cut in pieces and rustc refused the first ("must contain '=' between FROM and TO"), so no pull request could be built. They now go in CARGO_ENCODED_RUSTFLAGS, one flag apiece (release_flags and RenHDrum's a list; the game's Rust archive the same flag as before, by the same road). RenHDrum's C flag -ffile-prefix-map=<work>=renhdrum, which the cc crate splits the same way, goes shell-quoted with CC_SHELL_ESCAPED_FLAGS=1 when its path has a space, and as before otherwise. The release-flags check names its paths as this system joins them, so it passes on Windows too. Co-Authored-By: Claude Opus 5.5 <[email protected]>Tested in game: Windows 11, RTX 5080, NVIDIA 621.40: the launcher's whole path for a pull request, all in a folder whose path has a space (and &, parentheses, non-ASCII). This branch's builder ran from-source on #2728's head (main's builder fails there with the player's --remap-path-prefix error); the pull request's builder it made then built the game (3:04); the game prepared its shaders into that folder's store and booted, writing its saves into the profile there.
@review
Recommendation: Request changes. The reported Windows run shows that the original Rust flag failure is fixed. RenHDrum’s separate C flag handling still needs a real build on a system that compiles it. (It stands on L2: The check
CI / Third-party parts and guide screenshots (pull_request)fails on this head and passes on the base branch: Failing after 12s.)The builder passes Rust flags as separate arguments so source builds can work in cache paths containing spaces, and quotes RenHDrum’s C prefix-map flag for the same case. The change adds a small amount of argument-handling code without changing the intended compiler flags.
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.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
builder/crates/longshot-builder/src/from_source/mod.rs:436: The new RenHDrum C flag quoting has not been exercised by a real cc compilation. (more on the line) Do: Run from-source on Linux with an archiver and a cache path containing a space, and confirm RenHDrum compiles and the resulting builder works. Also exercise the Windows archiver path when available.@fixcan do L2.Checks: Still running: 7 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for the reported Windows case: main failed with the remap-path-prefix error, while this branch built the pull request’s builder and then the game in the same spaced path. RenHDrum was skipped in that run, so its fix remains unproven.
Other systems: The Rust archive and builder compilation use the same encoded flag path; the reported Windows run exercised both. Linux and Windows installations with an archiver can also compile RenHDrum, whose cc flag parsing was not exercised by that run. GPU rendering and gameplay code are unchanged.
Switches: No Longshot player switch was added or changed. CC_SHELL_ESCAPED_FLAGS is set to 1 only for RenHDrum builds whose work path contains ASCII whitespace; otherwise it is unset.
Reviewed:
3838cf15adagainst22d0d20098: Read AGENTS.md, CONTRIBUTING.md, the pull request template, standards, both changed Rust files, the changed documentation passage, the diff, commits, relevant callers and reported runs. Skimmed the rest of build.md. docs/review-checklist.md and ../Tooling/AGENTS.md were absent; no generated files or translations changed.; nothing run (a code review).Checked and fine:
Testing: No commands from the project were run, as requested. The supplied CI has one head-only failure and several checks still running; the bot handles the failure.
Overlaps and merge order: Not checked; network access is unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@ -437,3 +434,3 @@(format!("CFLAGS_{under}"), format!("-ffile-prefix-map={}=renhdrum", work.display())),];env.extend(cargo::prefix_map_cflags(&under, &work, "renhdrum"));let built = if cfg!(windows) { "renhdrum.dll" } else { "librenhdrum.so" };L1 (should fix): The new RenHDrum C flag quoting has not been exercised by a real cc compilation.
When: When an archiver is present and the cache path contains a space, from-source builds RenHDrum using this quoted CFLAGS value; the reported Windows run skipped that branch, and the unit test checks only the constructed strings.
Do: Run from-source on Linux with an archiver and a cache path containing a space, and confirm RenHDrum compiles and the resulting builder works. Also exercise the Windows archiver path when available.
@fix
Nothing needed changing: the review's items are already done.
Not done
For the author (no edit does these)
builder/crates/longshot-builder/src/from_source/mod.rs:436: The new RenHDrum C flag quoting has not been exercised by a real cc compilation. When: When an archiver is present and the cache path contains a space, from-source builds RenHDrum using this quoted CFLAGS value; the reported Windows run skipped that branch, and the unit test checks only the constructed strings. Do: Run from-source on Linux with an archiver and a cache path containing a space, and confirm RenHDrum compiles and the resulting builder works. Also exercise the Windows archiver path when available.Nothing was pushed.
Automated fix by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
Answers to the review. No code changed and nothing was pushed: the head is still
3838cf15.L2,
CI / Third-party parts and guide screenshots: this branch didn't cause it.python3 -I -B scripts/check_guide_screenshots.py --review-sources(the step that fails) gives the same 14REVIEW REQUIREDissues on main at22d0d200as on this branch. The two outputs are byte-identical; for example,settings-graphics.png: gpu/vk/vk_menu.cpp changed since reviewed revision.builder/crates/longshot-builder/src/from_source/and one paragraph ofdocs/dev/reference/build.md, none of the screenshots' sources.L1, a real RenHDrum compile through cc: done on Windows, in a folder with a space in its path. Both runs did
from-sourceof #2728 with anllvm-ar(LLVM 23.1.5, from a full llvm-mingw) on PATH, so RenHDrum is compiled rather than skipped.renhdrum: renhdrum.dll compiled in 20 s, withCFLAGS_x86_64_pc_windows_gnullvmquoted andCC_SHELL_ESCAPED_FLAGS=1. It's packed, then the pull request's builder compiles and its--versionreads the pack (245 s in all).no such file or directory: 'ünï\…\renhdrum\work=renhdrum'.Linux, with tools.lock's llvm, stays under Still to test (by hand). The description's Testing now has both runs.
3838cf15ad6b9cb765f2Rebased onto main at
bd7bcb52, which includes #2724 (the stale guide screenshots) and #2732 (the Python twin of this fix). The rebase was clean, and the new head is6b9cb765.check_guide_screenshots.py --review-sourcesnow reports one, and main atbd7bcb52reports exactly the same one:settings-graphics.png: gpu/vk/device_policy.h changed since reviewed revision b31dccae, from #2730, which merged after #2724. This branch doesn't touch that file, so that check stays red until main's own review hash is updated.tests/hint: no check reads the changed files. The match istest_dev_ab.py'stest_wired_from_source, a test ofdev.py ab's switch scan with "from_source" only in its name. The description now says so.--remap-path-prefix must contain '=', and the 17from_sourcetests pass on the head. Main's new commits change nothing underfrom_source/, so the Windows runs in Testing still hold.Rebased onto main at
3b42f60d(#2741, #2760, neither touches from_source/): clean, head33f5a177; the 17 from_source tests pass and formatting is clean. The guide-screenshot check still fails on main's own #2730 issue (settings-graphics.png, device_policy.h), not this branch.6b9cb765f233f5a1770ddev compile, and a failure there says what the builder said #2774