Skip to content

Commit

Permalink
Make the crate disambiguator 128 bits instead of 256 bits.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Oct 30, 2016
1 parent bd1ce91 commit 9ef9194
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,14 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
pub fn compute_crate_disambiguator(session: &Session) -> String {
use std::hash::Hasher;

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

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

0 comments on commit 9ef9194

Please sign in to comment.