Skip to content

Commit 5f60e34

Browse files
committed
Use ccache for stage0 tool and rustc builds
1 parent 52882f6 commit 5f60e34

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,16 @@ 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+
if compiler.stage == 0 && !builder.config.incremental {
1287+
cargo.env("RUSTC_WRAPPER", ccache);
1288+
}
1289+
}
1290+
12811291
rustc_cargo_env(builder, cargo, target, compiler.stage);
12821292
}
12831293

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,16 @@ 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+
if matches!(self.mode, Mode::ToolBootstrap) && !builder.config.incremental {
157+
cargo.env("RUSTC_WRAPPER", ccache);
158+
}
159+
}
160+
151161
// Rustc tools (miri, clippy, cargo, rustfmt, rust-analyzer)
152162
// could use the additional optimizations.
153163
if self.mode == Mode::ToolRustc && is_lto_stage(&self.compiler) {

0 commit comments

Comments
 (0)