Skip to content

Commit 2233f51

Browse files
committed
Auto merge of #4065 - michaelwoerister:smarter-cargo-incremental, r=alexcrichton
Only compile user-modifiable projects incrementally. Fixes #3972. Thanks for pointing me to the correct implementation, Alex! r? @alexcrichton
2 parents 2b32084 + 9e824c3 commit 2233f51

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: src/cargo/ops/cargo_rustc/context.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,11 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
904904
}
905905

906906
pub fn incremental_args(&self, unit: &Unit) -> CargoResult<Vec<String>> {
907-
if self.incremental_enabled {
907+
// Only enable incremental compilation for sources the user can modify.
908+
// For things that change infrequently, non-incremental builds yield
909+
// better performance.
910+
// (see also https://github.com/rust-lang/cargo/issues/3972)
911+
if self.incremental_enabled && unit.pkg.package_id().source_id().is_path() {
908912
Ok(vec![format!("-Zincremental={}", self.layout(unit.kind).incremental().display())])
909913
} else {
910914
Ok(vec![])

0 commit comments

Comments
 (0)