File tree 4 files changed +42
-5
lines changed
src/test/run-make/emit-path-unhashed
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() {
152
152
v2. output_types = OutputTypes :: new ( & [ ( OutputType :: Exe , Some ( PathBuf :: from ( "/some/thing" ) ) ) ] ) ;
153
153
v3. output_types = OutputTypes :: new ( & [ ( OutputType :: Exe , None ) ] ) ;
154
154
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) ;
158
158
}
159
159
160
160
#[ test]
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ use std::collections::btree_map::{
31
31
} ;
32
32
use std:: collections:: { BTreeMap , BTreeSet } ;
33
33
use std:: fmt;
34
+ use std:: hash:: { Hash , Hasher } ;
34
35
use std:: iter:: { self , FromIterator } ;
35
36
use std:: path:: { Path , PathBuf } ;
36
37
use std:: str:: { self , FromStr } ;
@@ -325,10 +326,19 @@ impl Default for TrimmedDefPaths {
325
326
326
327
/// Use tree-based collections to cheaply get a deterministic `Hash` implementation.
327
328
/// *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 ) ]
330
332
pub struct OutputTypes ( BTreeMap < OutputType , Option < PathBuf > > ) ;
331
333
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
+
332
342
impl_stable_hash_via_hash ! ( OutputTypes ) ;
333
343
334
344
impl 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