File tree 3 files changed +43
-4
lines changed
3 files changed +43
-4
lines changed Original file line number Diff line number Diff line change @@ -513,10 +513,24 @@ fn compute_metadata<'a, 'cfg>(
513
513
// Throw in the rustflags we're compiling with.
514
514
// This helps when the target directory is a shared cache for projects with different cargo configs,
515
515
// or if the user is experimenting with different rustflags manually.
516
- if unit. mode . is_doc ( ) {
517
- cx. bcx . rustdocflags_args ( unit) . hash ( & mut hasher ) ;
516
+ let mut flags = if unit. mode . is_doc ( ) {
517
+ cx. bcx . rustdocflags_args ( unit)
518
518
} else {
519
- cx. bcx . rustflags_args ( unit) . hash ( & mut hasher) ;
519
+ cx. bcx . rustflags_args ( unit)
520
+ }
521
+ . into_iter ( ) ;
522
+
523
+ // Ignore some flags. These may affect reproducible builds if they affect
524
+ // the path. The fingerprint will handle recompilation if these change.
525
+ while let Some ( flag) = flags. next ( ) {
526
+ if flag. starts_with ( "--remap-path-prefix=" ) {
527
+ continue ;
528
+ }
529
+ if flag == "--remap-path-prefix" {
530
+ flags. next ( ) ;
531
+ continue ;
532
+ }
533
+ flag. hash ( & mut hasher) ;
520
534
}
521
535
522
536
// Artifacts compiled for the host should have a different metadata
Original file line number Diff line number Diff line change 59
59
//! Target flags (test/bench/for_host/edition) | ✓ |
60
60
//! -C incremental=… flag | ✓ |
61
61
//! mtime of sources | ✓[^3] |
62
- //! RUSTFLAGS/RUSTDOCFLAGS | ✓ |
62
+ //! RUSTFLAGS/RUSTDOCFLAGS | ✓ | ✓
63
63
//!
64
64
//! [^1]: Build script and bin dependencies are not included.
65
65
//!
Original file line number Diff line number Diff line change @@ -1359,3 +1359,28 @@ fn env_rustflags_misspelled_build_script() {
1359
1359
. with_stderr_contains ( "[WARNING] Cargo does not read `RUST_FLAGS` environment variable. Did you mean `RUSTFLAGS`?" )
1360
1360
. run ( ) ;
1361
1361
}
1362
+
1363
+ #[ test]
1364
+ fn reamp_path_prefix_ignored ( ) {
1365
+ // Ensure that --remap-path-prefix does not affect metadata hash.
1366
+ let p = project ( ) . file ( "src/lib.rs" , "" ) . build ( ) ;
1367
+ p. cargo ( "build" ) . run ( ) ;
1368
+ let rlibs = p
1369
+ . glob ( "target/debug/deps/*.rlib" )
1370
+ . collect :: < Result < Vec < _ > , _ > > ( )
1371
+ . unwrap ( ) ;
1372
+ assert_eq ! ( rlibs. len( ) , 1 ) ;
1373
+ p. cargo ( "clean" ) . run ( ) ;
1374
+
1375
+ p. cargo ( "build" )
1376
+ . env (
1377
+ "RUSTFLAGS" ,
1378
+ "--remap-path-prefix=/abc=/zoo --remap-path-prefix /spaced=/zoo" ,
1379
+ )
1380
+ . run ( ) ;
1381
+ let rlibs2 = p
1382
+ . glob ( "target/debug/deps/*.rlib" )
1383
+ . collect :: < Result < Vec < _ > , _ > > ( )
1384
+ . unwrap ( ) ;
1385
+ assert_eq ! ( rlibs, rlibs2) ;
1386
+ }
You can’t perform that action at this time.
0 commit comments