Skip to content

Commit acf88cc

Browse files
committed
Auto merge of #7860 - ehuss:fix-std-collision, r=alexcrichton
Fix build-std collisions. `build-std` unit filenames can collide with user dependencies in some situations. In particular, `cc` as a build-dependency is likely to be exactly the same as a user's dep. This would result in the `cc` crate being built twice, but with the same filename, causing a collision. Other dependencies typically never collide because they have the `rustc-dep-of-std` feature, but build-dependencies do not. The solution here is to include `is_std` in the metadata hash. Fixes #7859.
2 parents 972b9f5 + acfb89a commit acf88cc

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

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

+10
Original file line numberDiff line numberDiff line change
@@ -587,5 +587,15 @@ fn compute_metadata<'a, 'cfg>(
587587
if let Ok(ref channel) = __cargo_default_lib_metadata {
588588
channel.hash(&mut hasher);
589589
}
590+
591+
// std units need to be kept separate from user dependencies. std crates
592+
// are differentiated in the Unit with `is_std` (for things like
593+
// `-Zforce-unstable-if-unmarked`), so they are always built separately.
594+
// This isn't strictly necessary for build dependencies which probably
595+
// don't need unstable support. A future experiment might be to set
596+
// `is_std` to false for build dependencies so that they can be shared
597+
// with user dependencies.
598+
unit.is_std.hash(&mut hasher);
599+
590600
Some(Metadata(hasher.finish()))
591601
}

src/cargo/core/compiler/fingerprint.rs

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
//! -C incremental=… flag | ✓ |
6161
//! mtime of sources | ✓[^3] |
6262
//! RUSTFLAGS/RUSTDOCFLAGS | ✓ |
63+
//! is_std | | ✓
6364
//!
6465
//! [^1]: Build script and bin dependencies are not included.
6566
//!

0 commit comments

Comments
 (0)