Skip to content

Commit 9e018f5

Browse files
Auto merge of #136942 - Kobzol:stage0-sccache, r=<try>
Use ccache for stage0 tool builds r? `@ghost` try-job: `x86_64-gnu-llvm-19*` try-job: `x86_64-msvc*` try-job: `x86_64-apple*` try-job: `dist-x86_64-linux` try-job: `mingw-check-*`
2 parents 52882f6 + 0505ee5 commit 9e018f5

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,17 @@ pub fn rustc_cargo(
12781278
));
12791279
}
12801280

1281+
// The stage0 compiler changes infrequently and does not directly depend on code
1282+
// in the current working directory. Therefore, caching it with sccache should be
1283+
// useful.
1284+
// This is only performed for non-incremental builds, as ccache cannot deal with these.
1285+
if let Some(ref ccache) = builder.config.ccache
1286+
&& compiler.stage == 0
1287+
&& !builder.config.incremental
1288+
{
1289+
cargo.env("RUSTC_WRAPPER", ccache);
1290+
}
1291+
12811292
rustc_cargo_env(builder, cargo, target, compiler.stage);
12821293
}
12831294

src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@ impl Step for ToolBuild {
148148
&self.extra_features,
149149
);
150150

151+
// The stage0 compiler changes infrequently and does not directly depend on code
152+
// in the current working directory. Therefore, caching it with sccache should be
153+
// useful.
154+
// This is only performed for non-incremental builds, as ccache cannot deal with these.
155+
if let Some(ref ccache) = builder.config.ccache
156+
&& matches!(self.mode, Mode::ToolBootstrap)
157+
&& !builder.config.incremental
158+
{
159+
cargo.env("RUSTC_WRAPPER", ccache);
160+
}
161+
151162
// Rustc tools (miri, clippy, cargo, rustfmt, rust-analyzer)
152163
// could use the additional optimizations.
153164
if self.mode == Mode::ToolRustc && is_lto_stage(&self.compiler) {

0 commit comments

Comments
 (0)