Skip to content

Commit cd8455c

Browse files
committed
Auto merge of #4169 - alexcrichton:beta-next, r=alexcrichton
[beta] Hash `Kind` in metadata for crates This fixes what is now a bug in Cargo discovered when attempting to land rust-lang/rust#42495 where Cargo will compile both host and target artifacts with the same `-C metadata` flag. This means that the compile can load two crates with the same SVH that are supposed to be distinct, which causes weird bugs with crate loading and whatnot. This commit throws in the `Kind` into the metadata calculation to resolve this to ensure that host/target artifacts always have a different `-C metadata`
2 parents b08dbc2 + 7177f56 commit cd8455c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/cargo/ops/cargo_rustc/context.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,11 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
477477
// settings like debuginfo and whatnot.
478478
unit.profile.hash(&mut hasher);
479479

480+
// Artifacts compiled for the host should have a different metadata
481+
// piece than those compiled for the target, so make sure we throw in
482+
// the unit's `kind` as well
483+
unit.kind.hash(&mut hasher);
484+
480485
// Finally throw in the target name/kind. This ensures that concurrent
481486
// compiles of targets in the same crate don't collide.
482487
unit.target.name().hash(&mut hasher);

0 commit comments

Comments
 (0)