Skip to content

[3/9] feat: strip basedirs from Rust hash key for cross-machine cache hits#10

Open
mmastrac wants to merge 1 commit intovercel/crate-type-allow-hashfrom
vercel/rust-basedirs
Open

[3/9] feat: strip basedirs from Rust hash key for cross-machine cache hits#10
mmastrac wants to merge 1 commit intovercel/crate-type-allow-hashfrom
vercel/rust-basedirs

Conversation

@mmastrac
Copy link
Copy Markdown
Collaborator

@mmastrac mmastrac commented Apr 2, 2026

Summary

  • Adds SCCACHE_BASEDIRS support to the Rust compiler hash key, matching the existing C compiler behavior
  • Strips basedir prefixes from cwd, CARGO_MANIFEST_DIR, CARGO_MANIFEST_PATH, CARGO_WORKSPACE_DIR, CARGO_TARGET_TMPDIR, CARGO_BIN_EXE_*, dep-info env var values, and the concatenated argument string (catches --remap-path-prefix, -Clinker=, etc.)
  • Enables cache hits when the same crate is compiled from different absolute paths on different machines
  • Addresses mozilla/sccache#2652

Test plan

  • test_basedirs_strips_cwd_and_cargo_manifest_dir — verifies basedirs changes the hash
  • test_basedirs_deterministic — verifies same basedir produces same hash
  • test_generate_hash_key — existing test updated for new hash format
  • All 37 Rust compiler tests pass
  • cargo clippy clean

🤖 Generated with Claude Code

SCCACHE_BASEDIRS now normalizes cwd, CARGO_MANIFEST_DIR,
CARGO_WORKSPACE_DIR, and dep-info env var values in the Rust
compiler's hash key computation. This enables cache hits when
the same crate is compiled from different absolute paths on
different machines (e.g., CI runners with different checkout dirs).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mmastrac mmastrac force-pushed the vercel/rust-basedirs branch from b8ee6b2 to 3f6f57a Compare April 2, 2026 17:18
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.

1 participant