@@ -434,7 +434,7 @@ impl Miri {
434434 builder : & Builder < ' _ > ,
435435 compiler : Compiler ,
436436 target : TargetSelection ,
437- ) -> String {
437+ ) -> PathBuf {
438438 let miri_sysroot = builder. out . join ( compiler. host . triple ) . join ( "miri-sysroot" ) ;
439439 let mut cargo = builder:: Cargo :: new (
440440 builder,
@@ -467,7 +467,7 @@ impl Miri {
467467 // Output is "<sysroot>\n".
468468 let sysroot = stdout. trim_end ( ) ;
469469 builder. verbose ( || println ! ( "`cargo miri setup --print-sysroot` said: {sysroot:?}" ) ) ;
470- sysroot . to_owned ( )
470+ PathBuf :: from ( sysroot )
471471 }
472472}
473473
@@ -520,12 +520,14 @@ impl Step for Miri {
520520 builder. ensure ( compile:: Std :: new ( target_compiler, host) ) ;
521521 let host_sysroot = builder. sysroot ( target_compiler) ;
522522
523- // Miri has its own "target dir" for ui test dependencies. Make sure it gets cleared
524- // properly when rustc changes. Similar to `Builder::cargo`, we skip this in dry runs to
525- // make sure the relevant compiler has been set up properly.
523+ // Miri has its own "target dir" for ui test dependencies. Make sure it gets cleared when
524+ // the sysroot gets rebuilt, to avoid "found possibly newer version of crate `std`" errors.
526525 if !builder. config . dry_run ( ) {
527526 let ui_test_dep_dir = builder. stage_out ( host_compiler, Mode :: ToolStd ) . join ( "miri_ui" ) ;
528- builder. clear_if_dirty ( & ui_test_dep_dir, & builder. rustc ( host_compiler) ) ;
527+ // It currently seems to be the case that the mtime of `miri_sysroot` changes when
528+ // the sysroot gets rebuilt. If that ever stops happening, we'll have to make
529+ // Miri explicitly update the mtime so that the logic here keeps working.
530+ builder. clear_if_dirty ( & ui_test_dep_dir, & miri_sysroot) ;
529531 }
530532
531533 // Run `cargo test`.
0 commit comments