File tree Expand file tree Collapse file tree 4 files changed +42
-5
lines changed
src/test/run-make/emit-path-unhashed Expand file tree Collapse file tree 4 files changed +42
-5
lines changed Original file line number Diff line number Diff line change @@ -152,9 +152,9 @@ fn test_output_types_tracking_hash_different_paths() {
152152 v2. output_types = OutputTypes :: new ( & [ ( OutputType :: Exe , Some ( PathBuf :: from ( "/some/thing" ) ) ) ] ) ;
153153 v3. output_types = OutputTypes :: new ( & [ ( OutputType :: Exe , None ) ] ) ;
154154
155- assert_different_hash ( & v1, & v2) ;
156- assert_different_hash ( & v1, & v3) ;
157- assert_different_hash ( & v2, & v3) ;
155+ assert_same_hash ( & v1, & v2) ;
156+ assert_same_hash ( & v1, & v3) ;
157+ assert_same_hash ( & v2, & v3) ;
158158}
159159
160160#[ test]
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ use std::collections::btree_map::{
3131} ;
3232use std:: collections:: { BTreeMap , BTreeSet } ;
3333use std:: fmt;
34+ use std:: hash:: { Hash , Hasher } ;
3435use std:: iter:: { self , FromIterator } ;
3536use std:: path:: { Path , PathBuf } ;
3637use std:: str:: { self , FromStr } ;
@@ -325,10 +326,19 @@ impl Default for TrimmedDefPaths {
325326
326327/// Use tree-based collections to cheaply get a deterministic `Hash` implementation.
327328/// *Do not* switch `BTreeMap` out for an unsorted container type! That would break
328- /// dependency tracking for command-line arguments.
329- #[ derive( Clone , Hash , Debug ) ]
329+ /// dependency tracking for command-line arguments. Also only hash keys, since tracking
330+ /// should only depend on the output types, not the paths they're written to.
331+ #[ derive( Clone , Debug ) ]
330332pub struct OutputTypes ( BTreeMap < OutputType , Option < PathBuf > > ) ;
331333
334+ impl Hash for OutputTypes {
335+ fn hash < H : Hasher > ( & self , hasher : & mut H ) {
336+ for k in self . keys ( ) {
337+ k. hash ( hasher) ;
338+ }
339+ }
340+ }
341+
332342impl_stable_hash_via_hash ! ( OutputTypes ) ;
333343
334344impl OutputTypes {
Original file line number Diff line number Diff line change 1+ -include ../../run-make-fulldeps/tools.mk
2+
3+ OUT =$(TMPDIR ) /emit
4+
5+ # --emit KIND=PATH should not affect crate hash vs --emit KIND
6+ all : $(OUT ) /a/libfoo.rlib $(OUT ) /b/libfoo.rlib $(TMPDIR ) /libfoo.rlib
7+ $(RUSTC ) -Zls $(TMPDIR ) /libfoo.rlib > $(TMPDIR ) /base.txt
8+ $(RUSTC ) -Zls $(OUT ) /a/libfoo.rlib > $(TMPDIR ) /a.txt
9+ $(RUSTC ) -Zls $(OUT ) /b/libfoo.rlib > $(TMPDIR ) /b.txt
10+
11+ diff $(TMPDIR)/base.txt $(TMPDIR)/a.txt
12+ diff $(TMPDIR)/base.txt $(TMPDIR)/b.txt
13+
14+ # Default output name
15+ $(TMPDIR ) /libfoo.rlib : foo.rs
16+ $(RUSTC ) --emit link foo.rs
17+
18+ # Output named with -o
19+ $(OUT ) /a/libfoo.rlib : foo.rs
20+ mkdir -p $(OUT ) /a
21+ $(RUSTC ) --emit link -o $@ foo.rs
22+
23+ # Output named with KIND=PATH
24+ $(OUT ) /b/libfoo.rlib : foo.rs
25+ mkdir -p $(OUT ) /b
26+ $(RUSTC ) --emit link=$@ foo.rs
Original file line number Diff line number Diff line change 1+ #![ crate_type = "rlib" ]
You can’t perform that action at this time.
0 commit comments