Repository navigation
rust: spawn a long command line through a response file - #3026
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3026 +/- ##
==========================================
- Coverage 78.82% 74.76% -4.07%
==========================================
Files 75 75
Lines 45394 45542 +148
==========================================
- Hits 35783 34048 -1735
- Misses 9611 11494 +1883 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| } | ||
| } | ||
|
|
||
| /// The longest command line a process can be spawned with, where the platform limits it. |
There was a problem hiding this comment.
does it really need a 13 lines comment? please make it shorter :)
There was a problem hiding this comment.
Shortened :) Sorry, AGENTS.md already says so.
| (split_rust_response_file_args(&contents) == arguments).then_some(contents) | ||
| } | ||
|
|
||
| /// The arguments to spawn rustc with for a compile that asks for `arguments`, and the |
There was a problem hiding this comment.
same here, nobody will read such a long comment, 2-3 lines are enough
There was a problem hiding this comment.
Same as above, shortened.
| /// a space or a tab, and escaping the backslashes and the quotes inside the quotes, so | ||
| /// this counts for each of them a separator, both quotes, and an escape for every byte | ||
| /// that can take one: never less than the characters Windows counts. | ||
| fn command_line_len(executable: &Path, arguments: &[OsString]) -> usize { |
There was a problem hiding this comment.
this overcounts a lot with windows paths (every \ counted twice), fine as an upper bound but could you please say so in one line?
There was a problem hiding this comment.
Right, it’s counted as an upper bound. Said so in a short comment.
| #[test] | ||
| fn test_arguments_for_spawn_keeps_arguments_a_response_file_would_change() { | ||
| let rustc = Path::new("rustc"); | ||
| let long: Vec<OsString> = (0..1000) |
There was a problem hiding this comment.
same long as in the previous test, could be dedup, no?
There was a problem hiding this comment.
Moved it into long_arguments(), which both tests now use.
A rustc command line that Windows cannot spawn -- `CreateProcessW` takes at most 32,767 characters and fails with os error 206 above that -- now goes to rustc as a single `@<path>`, the way cargo spawns rustc itself when its command line is too long. sccache expands an `@file` argument to see the arguments it holds (mozilla#2782), but spawned rustc with the expanded list, so every compile cargo could only spawn through a response file failed under sccache (mozilla#2787): `cargo build --target wasm32-unknown-unknown` of a crate depending on web-sys failed with `sccache: failed to spawn rustc ... (os error 206)`, where the command line is 43,897 characters, 40,932 of them the `--check-cfg` of web-sys' 1,500 features. This is a regression of v0.17.0 over v0.16.0, which passed the `@file` through to rustc as one argument that it could not parse. The three places that spawn rustc with the arguments of the compile -- the `--emit dep-info` run for the source files (where the failure above came from), the `--print file-names` run for the outputs, and the compile itself -- now collapse them back into a response file when the command line is too long for the platform. The response file is the arguments themselves, so the compile that runs is the one that was asked for, and the cache key, taken from the arguments, is the same either way, so CACHE_VERSION does not change. Arguments a response file cannot hold unchanged (a newline, surrounding whitespace, an empty argument, a leading `@`, or bytes that are not UTF-8) keep the whole command line as it is, where the spawn fails as it would have without sccache, rather than compiling something else than what was asked: what rustc will read back is compared against the arguments before the file is used. Unix passes the arguments as a vector, under a limit (`ARG_MAX`) that no rustc command line comes near, and is left alone. Tests: `cargo test --locked --lib --bins` 637 passed, 0 failed, exit 0; `cargo fmt -- --check` and the AGENTS.md clippy line are clean. The new `test_generate_compile_commands_response_file` fails without the fix (`spawned with one @file rather than 2011 arguments`, exit 101, checked by putting the limit back to `None`). The dep-info mock of the test harness now expands a response file, as rustc does, rather than failing to find `-o` in the arguments, and `hash_key_with` is split into a `hash_result_with` that the new test uses for the compilation. Fixes mozilla#2787 Co-Authored-By: Claude Opus 5 <[email protected]>
43830ac to
ded12b5
Compare
…er removed - Windows and Unix builds make the release patch (skate-patch/1) and its chain index next to the full package. - The Windows game build goes through sccache again: cargo's build folder moves to D:\b, so sccache's expanded rustc line fits the Windows command line limit (bevy_internal about 29,000 of 32,767 characters; without it all of Bevy rebuilt on every run). Drop it once an sccache release has the fix (mozilla/sccache#3026). - The in-game updater files are removed; Build-Release names the repository once; publish_branch wording.
sccache 0.19.0 expands cargo's @argfile and spawns rustc with the whole line; bevy_internal's (312 -L paths, 38,403 characters even with a short build folder) is past Windows' 32,767 limit, so the D:\b build folder failed with os error 206 (mozilla/sccache#2397). The Windows builds now build sccache 0.19.0 with .github/sccache/0001-rustc-response-file.patch (rustc gets a response file again when the line is too long: the compile, the dep-info and the file-names calls), cache it per patch, and put it first on PATH. The short build folder is gone again. Checked on the desktop: the patch applies to a fresh v0.19.0 clone (LF and CRLF checkouts), builds with --no-default-features --features gha, its unit tests pass, and a crate with a 60,000-character rustc line compiles through it (miss, then a hit after cargo clean). Drop the patch once an sccache release has the fix (mozilla/sccache#3026).
|
Thanks for your PR |
Since Cargo 1.100, sccache makes rustc's command line exceed the Windows length limit (os error 206) until mozilla/sccache#3026 ships. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…enshots vendored registration - Rust 1.100 passes one -L dependency per dependency build-script out dir, pushing leaf-crate rustc command lines past the Windows 32K CreateProcess limit. Cargo falls back to a response file, but sccache (<= 0.19) expands it flat before re-spawning rustc, so the spawn fails with os error 206 and killed the v1.0.10-beta.17 Windows desktop package twice. The upstream response-file passthrough (mozilla/sccache#3026) is not released yet: clear RUSTC_WRAPPER on Windows in setup-sccache so every cargo job keeps cargo's own response-file handling. Remove the step once a released sccache contains the fix. - Register third_party/screenshots in the workspace exclude and the core boundaries vendored registry like eioc/tao/wry, so cargo metadata and the boundary classification pass again under the 1.100 runner toolchain. - Ship the vendored screenshots crate in the miniapp market build context.
- sccache v0.16.0 on Windows in rust-test and statement-depth: 0.17 to 0.19 spawn rustc with the expanded argfile, over the Windows command-line limit since cargo 1.100 (os error 206) - back to the latest once a release has mozilla/sccache#3026
Cargo's newer build layout adds enough dependency search paths to exceed the Windows process command-line limit when compiling crates such as mux. Cargo handles this with response files, but released sccache versions expand those files and spawn rustc with the oversized argument list, failing with Windows error 206 before compilation starts. Bypass the Rust compiler wrapper and skip sccache setup in Windows PR, continuous, and tag jobs. Keep dependency caching, packaging paths, and Linux/macOS compiler caching unchanged, and regenerate the workflows from their source. The upstream response-file fix is merged but is not included in the latest sccache release, v0.19.0. Re-enable Windows compiler caching once a release includes mozilla/sccache#3026.
Cargo 1.100 lays out build artifacts one directory per unit and passes an -L for each dependency. Under R CMD check's deep source path the rustc command line for datafusion-physical-plan passes Windows' 32767 character limit. Cargo would retry through an argfile, but sccache 0.17.0 to 0.19.0 expands that argfile and spawns rustc with the full command line, which fails with os error 206 (mozilla/sccache#2397). The fix, mozilla/sccache#3026, is merged but not released. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* ci(windows): run the R CMD check without sccache Cargo 1.100 lays out build artifacts one directory per unit and passes an -L for each dependency. Under R CMD check's deep source path the rustc command line for datafusion-physical-plan passes Windows' 32767 character limit. Cargo would retry through an argfile, but sccache 0.17.0 to 0.19.0 expands that argfile and spawns rustc with the full command line, which fails with os error 206 (mozilla/sccache#2397). The fix, mozilla/sccache#3026, is merged but not released. * docs(upstream): track mozilla/sccache#3026 for the Windows job (#2353) sccache 0.17.0 to 0.19.0 spawns rustc with the expanded argfile, which passes Windows' command-line limit under cargo 1.100's build-dir layout. Record the upstream fix, our workaround and when to turn sccache back on. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ache rate limits (#2397) * ci: pin sccache to 0.19.0; 0.20.0 times out starting its server sccache-action installs the latest sccache release unless a version is given. sccache 0.20.0 was released 2026-11-23 07:08 UTC. Since then Rust-compiling jobs fail at random at `rustc -vV` with "Timed out waiting for server startup": all 11 failed jobs in the runs of #2393, #2382 and #2378 on 97075aa failed this way, on 0.20.0. The server logs (SCCACHE_ERROR_LOG) show why. At startup the server reads and writes `.sccache_check` in the GitHub Actions cache, and the cache API answered 429 (rate limit exceeded). 0.20.0 wraps the GHA backend in a retry layer (mozilla/sccache#2911: six retries, up to 8 s apart), which covers that check, so the server is still retrying when the client gives up after 10 s. 0.19.0 has no retry layer: a rate-limited check starts the server at once (read-only for the job if the write failed). The rate limiting most likely comes from bursts of runs on a cold cache: the cache namespace carries sccache's version, so 0.20.0 started from an empty cache. Pin version: "v0.19.0" on every sccache-action step (ci.yml x14, gctorture-nightly.yml x1). Tracked in #2396. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(upstream): sccache #3026 is released in 0.20.0; CI pins 0.19.0 v0.20.0 includes mozilla/sccache#3026, which the Windows job waits for before it sets RUSTC_WRAPPER=sccache again. CI now pins v0.19.0 (#2396), so that wait now runs through #2396 too. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(upstream): record sccache 0.20.0's startup timeout under GHA rate limits The cause of #2396 lives in sccache: the GHA retry layer added in mozilla/sccache#2911 (v0.20.0) also covers the server's startup cache check, so under HTTP 429 the server outlasts the client's 10 s wait. No upstream issue exists; the note is named after the PR that introduced the behaviour and records the workaround (the pin, or SCCACHE_SKIP_CACHE_CHECK=true) and when it can go. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Zed v1.31.0-pre 升级到 Rust 1.100.0 后 rustc 参数超过 Windows 命令行上限, Chocolatey 源的 sccache v0.19.0 无法处理;v0.20.0 起改用响应文件传参 (mozilla/sccache#3026)。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pins Dependabot does not cover were a week behind current stable. Keep generated C# and browser HTML on the new formatter defaults. sccache 0.20.1 re-spawns rustc via a response file, so Windows CI can keep RUSTC_WRAPPER (mozilla/sccache#3026). Co-authored-by: Sargun Vohra <[email protected]>
sccache 0.17.0 to 0.19.0 spawned rustc with the whole command line of cargo's argfile, which under R CMD check's deep path passed Windows' 32767-character limit (os error 206) once Cargo 1.100 passed one -L per dependency. v0.20.0 includes mozilla/sccache#3026, which spawns rustc through a response file, and every other job already pins it. The Windows job now pins v0.20.0 and sets RUSTC_WRAPPER=sccache again; upstream/sccache-3026-rustc-response-file.md and its index row go. Co-authored-by: Claude Opus 5.5 <[email protected]>
Since #2782, sccache expands an
@fileargument to see the arguments it holds, but it spawns rustc with the expanded list. cargo spawns rustc through a response file exactly when the command line is too long to spawn, so on Windows every such compile now fails under sccache (#2787):cargo build --target wasm32-unknown-unknownof a crate depending on web-sys fails withsccache: failed to spawn rustc ... (os error 206)for a command line of 43,897 characters, whereCreateProcessWtakes at most 32,767; 40,932 of them are the three--check-cfgof web-sys' ~1,500 features. v0.16.0 passed the@filethrough to rustc as one argument, so this is a regression of v0.17.0, and it hits any Windows build with a feature-heavy crate.The three places that spawn rustc with the arguments of the compile — the
--emit dep-inforun for the source files (where the failure above comes from), the--print file-namesrun for the outputs, and the compile itself — now collapse them back into a single@<path>when the command line is too long for the platform, which is what cargo does. The file holds the arguments themselves, so the compile that runs is the one that was asked for, and the cache key, taken from the arguments before this, is unchanged:CACHE_VERSIONdoes not move. Arguments a response file cannot pass to rustc unchanged (a newline, surrounding whitespace, an empty argument, a leading@, or bytes that are not UTF-8) keep the whole command line as it is, where the spawn fails as it would have without sccache, rather than compiling something else than what was asked — what rustc will read back is compared against the arguments before the file is used. Unix passes the arguments as a vector, under a limit (ARG_MAX) that no rustc command line comes near, and is left alone.Tested with unit tests in rust.rs:
cargo test --locked --lib --binspasses 637 tests, and the newtest_generate_compile_commands_response_filefails without the fix (spawned with one @file rather than 2011 arguments). Rancargo fmt -- --checkand the AGENTS.md clippy line. End to end on Windows, the cargo build above fails withos error 206with the binary from before this change and succeeds with it in 193 s; a second run gets 7/7 cache hits, so web-sys becomes cacheable. Both binaries in that end-to-end run are local builds carrying the same unrelated local changes, so this change is the only difference between them, but those numbers are not from a plain upstream build.hash_key_withis split into ahash_result_withthe new test uses, and the dep-info mock of the test harness expands a response file as rustc does.Fixes #2787
🤖 Generated with Claude Code