Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/Rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ sccache includes support for caching Rust compilation. This includes many caveat
* Procedural macros that read files from the filesystem may not be cached properly.
* `rustc`'s incremental compilation needs to be disabled. See [The Cargo Book](https://doc.rust-lang.org/cargo/reference/profiles.html#incremental)
* Crates that invoke the system linker cannot be cached. Examples are `bin`, `dylib`, `cdylib`, and `proc-macro` crates.
* `SCCACHE_BASEDIRS` normalizes paths in Rust cache keys when rustc's `--remap-path-prefix` covers the working directory with the default or `all` remap scope. Cached dep-info is rebuilt with output targets and dependency records from the current invocation.
* Path normalization remains location-sensitive when explicit external crates or dynamic libraries on crate search paths may invoke procedural macros, because they can observe physical paths without reporting a dependency to rustc.
* Rust path normalization is limited to ASCII paths on Windows.
* Distributed Rust compilation falls back to local compilation when `--remap-path-prefix` is used with a non-identity path transformer.

If you are using Rust 1.18 or later, you can ask cargo to wrap all compilation with sccache by setting `RUSTC_WRAPPER=sccache` in your build environment.
11 changes: 10 additions & 1 deletion src/compiler/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,11 @@ where
};

let hit = CompileResult::CacheHit(duration);
match entry.extract_objects(filtered_outputs, &pool).await {
let extraction = entry
.extract_objects(filtered_outputs, &pool)
.await
.and_then(|()| compilation.postprocess_cache_hit(&cwd));
match extraction {
Ok(()) => Ok(CacheLookupResult::Success(hit, output)),
Err(e) => {
if e.downcast_ref::<DecompressionFailure>().is_some() {
Expand Down Expand Up @@ -1112,6 +1116,11 @@ where
true
}

/// Adjust extracted outputs for the current invocation after a cache hit.
fn postprocess_cache_hit(&self, _cwd: &Path) -> Result<()> {
Ok(())
}

/// Returns an iterator over the results of this compilation.
///
/// Each item is a descriptive (and unique) name of the output paired with
Expand Down
Loading
Loading