Skip to content

fix: exclude CARGO_ENCODED_RUSTFLAGS from env var hash#2651

Merged
Xuanwo merged 1 commit intomozilla:mainfrom
weihanglo:encoded-rustflags
Mar 25, 2026
Merged

fix: exclude CARGO_ENCODED_RUSTFLAGS from env var hash#2651
Xuanwo merged 1 commit intomozilla:mainfrom
weihanglo:encoded-rustflags

Conversation

@weihanglo
Copy link
Copy Markdown
Contributor

For normal crate compilations, cargo consumes CARGO_ENCODED_RUSTFLAGS and passes the flags as command-line arguments to rustc. They are already hashed as part of the argument list (step 3), so hashing the env var is redundant.

For build-script probe compilations (like proc-macro2's autocfg probes), the build script inherits the env var but does NOT pass those flags to its probe rustc invocation. The flags are irrelevant to the probe's output. Even if they passes it, it will then be in the argument list.

In both cases, the env var value may contain build-specific paths, for example, --remap-path-prefix=/random/build/path=.... Those may cause unnecessary cache misses across builds.


While we have #2494 and #2495, I think this is less controversial so posted it separately

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.38%. Comparing base (8d6cab9) to head (50e2399).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2651   +/-   ##
=======================================
  Coverage   73.38%   73.38%           
=======================================
  Files          68       68           
  Lines       37338    37340    +2     
=======================================
+ Hits        27400    27402    +2     
  Misses       9938     9938           

☔ View full report in Codecov by Sentry.
📢 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.

For normal crate compilations, cargo consumes CARGO_ENCODED_RUSTFLAGS
and passes the flags as command-line arguments to rustc. They are
already hashed as part of the argument list (step 3), so hashing the
env var is redundant.

For build-script probe compilations (like proc-macro2's autocfg probes),
the build script inherits the env var but does NOT pass those flags to
its probe rustc invocation. The flags are irrelevant to the probe's
output. Even if they passes it, it will then be in the argument list.

In both cases, the env var value may contain build-specific paths,
for example, `--remap-path-prefix=/random/build/path=...`.
Those may cause unnecessary cache misses across builds.
Copy link
Copy Markdown
Collaborator

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

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

Thank you!

@weihanglo
Copy link
Copy Markdown
Contributor Author

The failure doesn't look related to my change https://github.com/mozilla/sccache/actions/runs/23541569356/job/68531339909?pr=2651 🤔

@Xuanwo Xuanwo merged commit 029b1ea into mozilla:main Mar 25, 2026
50 of 51 checks passed
@Xuanwo
Copy link
Copy Markdown
Collaborator

Xuanwo commented Mar 25, 2026

Yes, I think they are not related. Merged!

@weihanglo weihanglo deleted the encoded-rustflags branch March 25, 2026 13:05
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