Skip to content

Commit 6a205a4

Browse files
Incrementalize compilation only for leaf crate
1 parent 3ab7fde commit 6a205a4

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

collector/src/execute.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,11 @@ impl<'a> CargoProcess<'a> {
233233
// env vars set, but it doesn't hurt to have them.
234234
.env("RUSTC", &*FAKE_RUSTC)
235235
.env("RUSTC_REAL", &self.compiler.rustc)
236-
.env(
237-
"CARGO_INCREMENTAL",
238-
&format!("{}", self.incremental as usize),
239-
)
236+
// We separately pass -Cincremental to the leaf crate --
237+
// CARGO_INCREMENTAL is cached separately for both the leaf crate
238+
// and any in-tree dependencies, and we don't want that; it wastes
239+
// time.
240+
.env("CARGO_INCREMENTAL", "0")
240241
.current_dir(cwd)
241242
.arg(subcommand)
242243
.arg("--manifest-path")
@@ -346,6 +347,13 @@ impl<'a> CargoProcess<'a> {
346347
}
347348
}
348349

350+
if self.incremental {
351+
cmd.arg("-C");
352+
let mut incr_arg = std::ffi::OsString::from("incremental=");
353+
incr_arg.push(self.cwd.join("incremental-state"));
354+
cmd.arg(incr_arg);
355+
}
356+
349357
log::debug!("{:?}", cmd);
350358

351359
let output = command_output(&mut cmd)?;
@@ -969,14 +977,9 @@ impl Benchmark {
969977
// Build everything, including all dependent crates, in a temp dir with
970978
// the first build kind we're building for. The intent is to cache build
971979
// dependencies at least between runs.
972-
//
973-
// Cache with both incremental and non-incremental.
974980
let prep_dir = self.make_temp_dir(&self.path)?;
975981
self.mk_cargo_process(compiler, prep_dir.path(), build_kinds[0])
976982
.run_rustc()?;
977-
self.mk_cargo_process(compiler, prep_dir.path(), build_kinds[0])
978-
.incremental(true)
979-
.run_rustc()?;
980983

981984
for &build_kind in build_kinds {
982985
eprintln!("Running {}: {:?} + {:?}", self.name, build_kind, run_kinds);

0 commit comments

Comments
 (0)