Skip to content
Merged
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
11 changes: 11 additions & 0 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,17 @@ pub fn rustc_cargo(
));
}

// The stage0 compiler changes infrequently and does not directly depend on code
// in the current working directory. Therefore, caching it with sccache should be
// useful.
// This is only performed for non-incremental builds, as ccache cannot deal with these.
if let Some(ref ccache) = builder.config.ccache
&& compiler.stage == 0
&& !builder.config.incremental
{
cargo.env("RUSTC_WRAPPER", ccache);
}

rustc_cargo_env(builder, cargo, target, compiler.stage);
}

Expand Down
11 changes: 11 additions & 0 deletions src/bootstrap/src/core/build_steps/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ impl Step for ToolBuild {
&self.extra_features,
);

// The stage0 compiler changes infrequently and does not directly depend on code
// in the current working directory. Therefore, caching it with sccache should be
// useful.
// This is only performed for non-incremental builds, as ccache cannot deal with these.
if let Some(ref ccache) = builder.config.ccache
&& matches!(self.mode, Mode::ToolBootstrap)
&& !builder.config.incremental
{
cargo.env("RUSTC_WRAPPER", ccache);
}

// Rustc tools (miri, clippy, cargo, rustfmt, rust-analyzer)
// could use the additional optimizations.
if self.mode == Mode::ToolRustc && is_lto_stage(&self.compiler) {
Expand Down
Loading