@@ -461,24 +461,30 @@ impl Step for RustDemangler {
461461pub struct Miri {
462462 stage : u32 ,
463463 host : TargetSelection ,
464+ target : TargetSelection ,
464465}
465466
466467impl Step for Miri {
467468 type Output = ( ) ;
468- const ONLY_HOSTS : bool = true ;
469+ const ONLY_HOSTS : bool = false ;
469470
470471 fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
471472 run. path ( "src/tools/miri" )
472473 }
473474
474475 fn make_run ( run : RunConfig < ' _ > ) {
475- run. builder . ensure ( Miri { stage : run. builder . top_stage , host : run. target } ) ;
476+ run. builder . ensure ( Miri {
477+ stage : run. builder . top_stage ,
478+ host : run. build_triple ( ) ,
479+ target : run. target ,
480+ } ) ;
476481 }
477482
478483 /// Runs `cargo test` for miri.
479484 fn run ( self , builder : & Builder < ' _ > ) {
480485 let stage = self . stage ;
481486 let host = self . host ;
487+ let target = self . target ;
482488 let compiler = builder. compiler ( stage, host) ;
483489 // We need the stdlib for the *next* stage, as it was built with this compiler that also built Miri.
484490 // Except if we are at stage 2, the bootstrap loop is complete and we can stick with our current stage.
@@ -495,7 +501,7 @@ impl Step for Miri {
495501 builder. ensure ( compile:: Std :: new ( compiler_std, host) ) ;
496502 let sysroot = builder. sysroot ( compiler_std) ;
497503
498- // # Run `cargo miri setup`.
504+ // # Run `cargo miri setup` for the given target .
499505 let mut cargo = tool:: prepare_tool_cargo (
500506 builder,
501507 compiler,
@@ -508,6 +514,7 @@ impl Step for Miri {
508514 ) ;
509515 cargo. add_rustc_lib_path ( builder, compiler) ;
510516 cargo. arg ( "--" ) . arg ( "miri" ) . arg ( "setup" ) ;
517+ cargo. arg ( "--target" ) . arg ( target. rustc_target_arg ( ) ) ;
511518
512519 // Tell `cargo miri setup` where to find the sources.
513520 cargo. env ( "MIRI_LIB_SRC" , builder. src . join ( "library" ) ) ;
@@ -565,6 +572,9 @@ impl Step for Miri {
565572 cargo. env ( "MIRI_BLESS" , "Gesundheit" ) ;
566573 }
567574
575+ // Set the target.
576+ cargo. env ( "MIRI_TEST_TARGET" , target. rustc_target_arg ( ) ) ;
577+ // Forward test filters.
568578 cargo. arg ( "--" ) . args ( builder. config . cmd . test_args ( ) ) ;
569579
570580 let mut cargo = Command :: from ( cargo) ;
0 commit comments