diff options
| author | Michael Woerister <michaelwoerister@posteo> | 2017-10-25 16:49:55 +0200 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo> | 2017-10-25 16:49:55 +0200 |
| commit | 89909c76a37d38aab57462ffdae5bed7172b02e3 (patch) | |
| tree | 64ad3bd47f77791c35cbe37c2da874dfb9dc552a /src/librustc_data_structures | |
| parent | b2478052f88db8c8526ee2dc4a382da91eefc76c (diff) | |
| download | rust-89909c76a37d38aab57462ffdae5bed7172b02e3.tar.gz rust-89909c76a37d38aab57462ffdae5bed7172b02e3.zip | |
Fix 32 vs 64 bit platform instability in StableHasher.
Diffstat (limited to 'src/librustc_data_structures')
| -rw-r--r-- | src/librustc_data_structures/stable_hasher.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/librustc_data_structures/stable_hasher.rs b/src/librustc_data_structures/stable_hasher.rs index 831e113016f..4849210aed3 100644 --- a/src/librustc_data_structures/stable_hasher.rs +++ b/src/librustc_data_structures/stable_hasher.rs @@ -132,8 +132,11 @@ impl<W> Hasher for StableHasher<W> { #[inline] fn write_usize(&mut self, i: usize) { - self.state.write_usize(i.to_le()); - self.bytes_hashed += ::std::mem::size_of::<usize>() as u64; + // Always treat usize as u64 so we get the same results on 32 and 64 bit + // platforms. This is important for symbol hashes when cross compiling, + // for example. + self.state.write_u64((i as u64).to_le()); + self.bytes_hashed += 8; } #[inline] @@ -168,8 +171,11 @@ impl<W> Hasher for StableHasher<W> { #[inline] fn write_isize(&mut self, i: isize) { - self.state.write_isize(i.to_le()); - self.bytes_hashed += ::std::mem::size_of::<isize>() as u64; + // Always treat isize as i64 so we get the same results on 32 and 64 bit + // platforms. This is important for symbol hashes when cross compiling, + // for example. + self.state.write_i64((i as i64).to_le()); + self.bytes_hashed += 8; } } |
