Skip to content

Commit 9ef9194

Browse files
Make the crate disambiguator 128 bits instead of 256 bits.
1 parent bd1ce91 commit 9ef9194

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/librustc_driver/driver.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,14 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
12251225
pub fn compute_crate_disambiguator(session: &Session) -> String {
12261226
use std::hash::Hasher;
12271227

1228-
let mut hasher = ArchIndependentHasher::new(Blake2bHasher::new(256 / 8, &[]));
1228+
// The crate_disambiguator is a 128 bit hash. The disambiguator is fed
1229+
// into various other hashes quite a bit (symbol hashes, incr. comp. hashes,
1230+
// debuginfo type IDs, etc), so we don't want it to be too wide. 128 bits
1231+
// should still be safe enough to avoid collisions in practice.
1232+
// FIXME(mw): It seems that the crate_disambiguator is used everywhere as
1233+
// a hex-string instead of raw bytes. We should really use the
1234+
// smaller representation.
1235+
let mut hasher = ArchIndependentHasher::new(Blake2bHasher::new(128 / 8, &[]));
12291236

12301237
let mut metadata = session.opts.cg.metadata.clone();
12311238
// We don't want the crate_disambiguator to dependent on the order

0 commit comments

Comments
 (0)