Skip to content

Commit 7246028

Browse files
committed
Sort units once, not each call to dep_targets
The code lying around in `dep_targets` is pretty old at this point, but given the current iteraiton there's no need to re-sort on each call to `dep_targets`, only initially during construction!
1 parent 12e0ffa commit 7246028

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/cargo/core/compiler/context/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
380380
return Vec::new();
381381
}
382382
}
383-
let mut deps = self.unit_dependencies[unit].clone();
384-
deps.sort();
385-
deps
383+
self.unit_dependencies[unit].clone()
386384
}
387385

388386
pub fn is_primary_package(&self, unit: &Unit<'a>) -> bool {

src/cargo/core/compiler/context/unit_dependencies.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ pub fn build_unit_dependencies<'a, 'cfg>(
8787

8888
connect_run_custom_build_deps(&mut state);
8989

90+
// Dependencies are used in tons of places throughout the backend, many of
91+
// which affect the determinism of the build itself. As a result be sure
92+
// that dependency lists are always sorted to ensure we've always got a
93+
// deterministic output.
94+
for list in state.deps.values_mut() {
95+
list.sort();
96+
}
97+
9098
Ok(())
9199
}
92100

0 commit comments

Comments
 (0)