Skip to content

Commit 1656447

Browse files
committed
WIP
1 parent 8072fa1 commit 1656447

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

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

+14
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,20 @@ impl Step for Rustc {
10911091

10921092
rustc_cargo(builder, &mut cargo, target, &compiler, &self.crates);
10931093

1094+
// The stage0 compiler changes infrequently and does not directly depend on code
1095+
// in the current working directory. Therefore, caching it with sccache should be
1096+
// useful.
1097+
// This is only performed for non-incremental builds, as ccache cannot deal with these.
1098+
if let Some(ref ccache) = builder.config.ccache {
1099+
eprintln!(
1100+
"RUSTC SCCACHE CONFIGURED at {}, incremental: {}",
1101+
ccache, builder.config.incremental
1102+
);
1103+
if compiler.stage == 0 && !builder.config.incremental {
1104+
cargo.env("RUSTC_WRAPPER", ccache);
1105+
}
1106+
}
1107+
10941108
// NB: all RUSTFLAGS should be added to `rustc_cargo()` so they will be
10951109
// consistently applied by check/doc/test modes too.
10961110

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

+14
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,20 @@ 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+
eprintln!(
157+
"TOOL SCCACHE CONFIGURED at {}, mode: {:?}, incremental: {}",
158+
ccache, self.mode, builder.config.incremental
159+
);
160+
if matches!(self.mode, Mode::ToolBootstrap) && !builder.config.incremental {
161+
cargo.env("RUSTC_WRAPPER", ccache);
162+
}
163+
}
164+
151165
if path.ends_with("/rustdoc") &&
152166
// rustdoc is performance sensitive, so apply LTO to it.
153167
is_lto_stage(&self.compiler)

0 commit comments

Comments
 (0)