Skip to content

dist: include Rust sysroot in weak toolchain key - #2900

Merged
sylvestre merged 1 commit into
mozilla:mainfrom
codeandsolder:upstream-pr/rust-dist-toolchain-path-identity
Oct 11, 2026
Merged

sylvestre merged 1 commit into
mozilla:mainfrom
codeandsolder:upstream-pr/rust-dist-toolchain-path-identity

Conversation

@codeandsolder

Copy link
Copy Markdown
Contributor

Summary

Rust distributed toolchain archives preserve the sysroot's filesystem layout, including absolute paths, but the Rust weak toolchain key currently only incorporates compiler shared-library digests.

As a result, two otherwise-identical Rust toolchains installed at different sysroot paths can share the same weak key even though their packaged toolchain archives are path-sensitive. A persisted dist-client "weak_map" can then select an archive produced from the wrong installation layout.

Include the resolved Rust sysroot path in the distributed-toolchain weak key.

This intentionally does not change the normal compilation cache key, so equivalent toolchains installed at different locations can continue sharing ordinary object-cache entries.

A version/domain marker is also included in the new weak-key derivation so previously persisted mappings are not reused after upgrading.

Why this belongs in sccache

rustup already resolves the active compiler correctly before this point. Cargo also does not own sccache's distributed-toolchain packaging or "weak_map".

The collision happens specifically in sccache's dist-client toolchain identity: the weak key chooses a previously packaged archive, while that archive contains path-sensitive Rust sysroot contents.

Testing

  • Added a regression verifying that:
    • the same toolchain contents and sysroot produce the same weak key;
    • identical toolchain contents at different sysroot paths produce different weak keys.
  • "cargo +1.99.0 test --locked --no-default-features --lib rust_dist_toolchain_weak_key_tracks_sysroot_path"
  • Rust 1.99 through sccache

AI Disclosure: AI developed, human directed and reviewed

@codecov-commenter

codecov-commenter commented Oct 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.27%. Comparing base (49a4f5d) to head (9312728).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2900      +/-   ##
==========================================
+ Coverage   78.22%   78.27%   +0.05%     
==========================================
  Files          72       72              
  Lines       42007    42123     +116     
==========================================
+ Hits        32858    32972     +114     
- Misses       9149     9151       +2     

☔ 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.

Comment thread src/compiler/rust.rs Outdated
Comment thread src/compiler/rust.rs Outdated
@codeandsolder-git-wrangler
codeandsolder-git-wrangler Bot force-pushed the upstream-pr/rust-dist-toolchain-path-identity branch from 1abe22f to 9312728 Compare October 11, 2026 13:43
@sylvestre
sylvestre merged commit bab4d74 into mozilla:main Oct 11, 2026
51 checks passed
@sylvestre

Copy link
Copy Markdown
Collaborator

Thanks for your PR

@codeandsolder-git-wrangler
codeandsolder-git-wrangler Bot deleted the upstream-pr/rust-dist-toolchain-path-identity branch October 16, 2026 14:21
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.

3 participants