Skip to content

Add support for arg files in Rust - #2782

Merged
sylvestre merged 2 commits into
mozilla:mainfrom
ranger-ross:rust-arg-file
Jul 28, 2026
Merged

sylvestre merged 2 commits into
mozilla:mainfrom
ranger-ross:rust-arg-file

Conversation

@ranger-ross

@ranger-ross ranger-ross commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds support for arg files (aka response files) in Rust.

Cargo is planning to make some changes in rust-lang/cargo#15010 which will likely increase the total number of args passed to rustc, making sccache's lack of support for arg files more painful to users. (especially to windows users)

Comment thread src/compiler/rust.rs Outdated
};

let mut contents = String::new();
let res = fs_err::File::open(&file).and_then(|mut f| f.read_to_string(&mut contents));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be wrapped in a BufReader, to avoid doing many syscalls for each read? Not sure if read_to_string already handles that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point! The arg files can be decently large so seems like a good idea to do that.

There are some other reads in this file that as use read_to_string() but I think those are reading much smaller files so the they probably get everything in one syscall.

Updated in the latest push

@codecov-commenter

codecov-commenter commented Jul 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.57143% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 62.47%. Comparing base (7cd4f2c) to head (fe3f126).

Files with missing lines Patch % Lines
src/compiler/rust.rs 98.57% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (7cd4f2c) and HEAD (fe3f126). Click for more details.

HEAD has 6 uploads less than BASE
Flag BASE (7cd4f2c) HEAD (fe3f126)
13 7
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2782      +/-   ##
==========================================
- Coverage   70.90%   62.47%   -8.44%     
==========================================
  Files          71       71              
  Lines       40393    35979    -4414     
==========================================
- Hits        28642    22479    -6163     
- Misses      11751    13500    +1749     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 45.99%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 10 regressed benchmarks
✅ 48 untouched benchmarks
⏩ 6 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Memory lru_sequential_scan_pattern 128 B 260 B -50.77%
❌ Memory lru_hotcold_access_pattern 128 B 260 B -50.77%
❌ Memory hash_multiple_files 128 B 260 B -50.77%
❌ Memory time_macro_finder_chunked 128 B 260 B -50.77%
❌ Memory lru_cache_get_hit 128 B 260 B -50.77%
❌ Memory hash_large_data 192 B 324 B -40.74%
❌ Memory hash_header_file 192 B 324 B -40.74%
❌ Memory cache_key_generation 192 B 324 B -40.74%
❌ Memory time_macro_finder_with_macros 192 B 324 B -40.74%
❌ Memory time_macro_finder_no_macros 192 B 324 B -40.74%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing ranger-ross:rust-arg-file (fe3f126) with main (7cd4f2c)

Open in CodSpeed

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@sylvestre
sylvestre merged commit dd884c3 into mozilla:main Jul 28, 2026
48 of 51 checks passed
@ranger-ross
ranger-ross deleted the rust-arg-file branch July 28, 2026 12:50
lkwilson pushed a commit to lkwilson/red that referenced this pull request Jul 30, 2026
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [mozilla/sccache](https://github.com/mozilla/sccache) | minor | `0.16.0` → `0.17.0` |

---

### Release Notes

<details>
<summary>mozilla/sccache (mozilla/sccache)</summary>

### [`v0.17.0`](https://github.com/mozilla/sccache/releases/tag/v0.17.0)

[Compare Source](mozilla/sccache@v0.16.0...v0.17.0)

##### sccache 0.17.0

##### Summary

sccache 0.17.0 is a significant release: it introduces a **new client-side architecture**.

Until now, every compilation was handed off to the long-lived sccache server, which did the cache
lookup and ran the compiler. In client-side mode, the client process does that work itself - the
server is only consulted for the shared state it owns (compiler info, dist client, stats). This
removes a round-trip and the server-side bottleneck, and gives noticeably better results on
developer workstations.

Client-side mode is opt-in for now: enable it with the `SCCACHE_CLIENT_SIDE` environment variable
(or the `client_side_mode` config key). See [docs/Architecture.md](https://github.com/mozilla/sccache/blob/main/docs/Architecture.md#client-side-mode-sccache_client_side)
for the details.

Other highlights:

- **Response files**: gcc/clang builds using quoted `@response` files are now cached and
  distributed correctly ([#&#8203;2755](mozilla/sccache#2755), [#&#8203;2772](mozilla/sccache#2772)), and Rust `@argfile` arguments are supported ([#&#8203;2782](mozilla/sccache#2782)).
- **Distributed compilation**: compile tasks and their subprocesses are now aborted when a client
  disconnects, instead of running to completion on the build server ([#&#8203;2761](mozilla/sccache#2761), [#&#8203;2774](mozilla/sccache#2774)). The
  `ToolchainPackager` cfg gate was fixed so the dist code builds on ppc64le and s390x ([#&#8203;2749](mozilla/sccache#2749)).
- **S3 SSE-KMS**: server-side encryption with KMS keys is now supported ([#&#8203;2770](mozilla/sccache#2770)).
- **Diagnostics**: gcc color diagnostics now behave the same way as rustc's ([#&#8203;2758](mozilla/sccache#2758)).
- **Preprocessor correctness**: `-ivfsoverlay` is treated as a preprocessor-only argument ([#&#8203;2767](mozilla/sccache#2767)).

Welcome to 4 new contributors!

##### Client-side mode

- Initial client-side implementation by [@&#8203;glandium](https://github.com/glandium) in [#&#8203;2735](mozilla/sccache#2735)
- doc: document client-side and direct modes in Architecture.md by [@&#8203;sylvestre](https://github.com/sylvestre) in [#&#8203;2752](mozilla/sccache#2752)

##### Features

- gcc/clang: cache and distribute builds using quoted [@&#8203;response](https://github.com/response) files by [@&#8203;avikivity](https://github.com/avikivity) in [#&#8203;2755](mozilla/sccache#2755)
- Add support for arg files in Rust by [@&#8203;ranger-ross](https://github.com/ranger-ross) in [#&#8203;2782](mozilla/sccache#2782)
- feat: support S3 SSE-KMS by [@&#8203;jpadilla](https://github.com/jpadilla) in [#&#8203;2770](mozilla/sccache#2770)
- Make gcc diagnostics color output work the same as for rustc by [@&#8203;jwidauer](https://github.com/jwidauer) in [#&#8203;2758](mozilla/sccache#2758)
- Abort compile tasks and associated subprocesses when a client disconnects by [@&#8203;trxcllnt](https://github.com/trxcllnt) in [#&#8203;2761](mozilla/sccache#2761)

##### Fixes

- Fix ToolchainPackager cfg gate to build on ppc64le/s390x by [@&#8203;cryptomilk](https://github.com/cryptomilk) in [#&#8203;2749](mozilla/sccache#2749)
- treat -ivfsoverlay as a preprocessor-only argument by [@&#8203;glandium](https://github.com/glandium) in [#&#8203;2767](mozilla/sccache#2767)
- gcc: refine response-file tokenizer visibility and whitespace handling by [@&#8203;sylvestre](https://github.com/sylvestre) in [#&#8203;2772](mozilla/sccache#2772)
- Fix description of Unix socket-based Redis connection by [@&#8203;Toorero](https://github.com/Toorero) in [#&#8203;2769](mozilla/sccache#2769)

##### Cleanup

- Simplify the code from pr [#&#8203;2761](mozilla/sccache#2761) by [@&#8203;sylvestre](https://github.com/sylvestre) in [#&#8203;2774](mozilla/sccache#2774)
- tests: pin libc in the dist test crate by [@&#8203;sylvestre](https://github.com/sylvestre) in [#&#8203;2784](mozilla/sccache#2784)
- Release 0.17.0 by [@&#8203;sylvestre](https://github.com/sylvestre) in [#&#8203;2783](mozilla/sccache#2783)

##### New Contributors

- [@&#8203;jwidauer](https://github.com/jwidauer) made their first contribution in [#&#8203;2758](mozilla/sccache#2758)
- [@&#8203;jpadilla](https://github.com/jpadilla) made their first contribution in [#&#8203;2770](mozilla/sccache#2770)
- [@&#8203;ranger-ross](https://github.com/ranger-ross) made their first contribution in [#&#8203;2782](mozilla/sccache#2782)
- [@&#8203;Toorero](https://github.com/Toorero) made their first contribution in [#&#8203;2769](mozilla/sccache#2769)

**Full Changelog**: <mozilla/sccache@v0.16.0...v0.17.0>

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNTYuMCIsInVwZGF0ZWRJblZlciI6IjQzLjI1Ni4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

---------

Co-authored-by: Renovate Bot <[email protected]>
Reviewed-on: https://gitea.endsy.me/op/red/pulls/24
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
sccache 0.17.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre># sccache 0.17.0

## Summary

sccache 0.17.0 is a significant release: it introduces a **new client-side architecture**.

Until now, every compilation was handed off to the long-lived sccache server, which did the cache
lookup and ran the compiler. In client-side mode, the client process does that work itself - the
server is only consulted for the shared state it owns (compiler info, dist client, stats). This
removes a round-trip and the server-side bottleneck, and gives noticeably better results on
developer workstations.

Client-side mode is opt-in for now: enable it with the `SCCACHE_CLIENT_SIDE` environment variable
(or the `client_side_mode` config key). See [docs/Architecture.md](https://github.com/mozilla/sccache/blob/main/docs/Architecture.md#client-side-mode-sccache_client_side)
for the details.

Other highlights:

- **Response files**: gcc/clang builds using quoted `@response` files are now cached and
  distributed correctly (#2755, #2772), and Rust `@argfile` arguments are supported (#2782).
- **Distributed compilation**: compile tasks and their subprocesses are now aborted when a client
  disconnects, instead of running to completion on the build server (#2761, #2774). The
  `ToolchainPackager` cfg gate was fixed so the dist code builds on ppc64le and s390x (#2749).
- **S3 SSE-KMS**: server-side encryption with KMS keys is now supported (#2770).
- **Diagnostics**: gcc color diagnostics now behave the same way as rustc's (#2758).
- **Preprocessor correctness**: `-ivfsoverlay` is treated as a preprocessor-only argument (#2767).

Welcome to 4 new contributors!

## Client-side mode
* Initial client-side implementation by @glandium in mozilla/sccache#2735
* doc: document client-side and direct modes in Architecture.md by @sylvestre in mozilla/sccache#2752

## Features
* gcc/clang: cache and distribute builds using quoted @response files by @avikivity in mozilla/sccache#2755
* Add support for arg files in Rust by @ranger-ross in mozilla/sccache#2782
* feat: support S3 SSE-KMS by @jpadilla in mozilla/sccache#2770
* Make gcc diagnostics color output work the same as for rustc by @jwidauer in mozilla/sccache#2758
* Abort compile tasks and associated subprocesses when a client disconnects by @trxcllnt in mozilla/sccache#2761

## Fixes
* Fix ToolchainPackager cfg gate to build on ppc64le/s390x by @cryptomilk in mozilla/sccache#2749
* treat -ivfsoverlay as a preprocessor-only argument by @glandium in mozilla/sccache#2767
* gcc: refine response-file tokenizer visibility and whitespace handling by @sylvestre in mozilla/sccache#2772
* Fix description of Unix socket-based Redis connection by @Toorero in mozilla/sccache#2769

## Cleanup
* Simplify the code from pr #2761 by @sylvestre in mozilla/sccache#2774
* tests: pin libc in the dist test crate by @sylvestre in mozilla/sccache#2784
* Release 0.17.0 by @sylvestre in mozilla/sccache#2783

## New Contributors
* @jwidauer made their first contribution in mozilla/sccache#2758
* @jpadilla made their first contribution in mozilla/sccache#2770
* @ranger-ross made their first contribution in mozilla/sccache#2782
* @Toorero made their first contribution in mozilla/sccache#2769

**Full Changelog**: https://github.com/mozilla/sccache/compare/v0.16.0...v0.17.0</pre>
  <p>View the full release notes at <a href="https://github.com/mozilla/sccache/releases/tag/v0.17.0">https://github.com/mozilla/sccache/releases/tag/v0.17.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!15423
katout added a commit to katout/sccache that referenced this pull request Nov 11, 2026
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]>
sylvestre pushed a commit that referenced this pull request Nov 14, 2026
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 (#2782),
but spawned rustc with the expanded list, so every compile cargo could
only spawn through a response file failed under sccache (#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 #2787

Co-Authored-By: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants