Use ccache for stage0 tool and rustc builds

This commit is contained in:
Jakub Beránek 2025-06-02 13:23:24 +02:00
parent 52882f6522
commit 0505ee514b
No known key found for this signature in database
GPG key ID: 909CD0D26483516B
2 changed files with 22 additions and 0 deletions

View file

@ -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);
}

View file

@ -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) {