@@ -597,7 +597,7 @@ impl Step for Miri {
597597 builder. ensure ( compile:: Std :: new ( target_compiler, host) ) ;
598598 let host_sysroot = builder. sysroot ( target_compiler) ;
599599
600- // # Run `cargo test`.
600+ // Run `cargo test`.
601601 // This is with the Miri crate, so it uses the host compiler.
602602 let mut cargo = tool:: prepare_tool_cargo (
603603 builder,
@@ -652,15 +652,46 @@ impl Step for Miri {
652652 builder. run ( & mut cargo) ;
653653 }
654654 }
655+ }
656+ }
657+
658+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
659+ pub struct CargoMiri {
660+ target : TargetSelection ,
661+ }
662+
663+ impl Step for CargoMiri {
664+ type Output = ( ) ;
665+ const ONLY_HOSTS : bool = false ;
655666
656- // # Run `cargo miri test`.
667+ fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
668+ run. path ( "src/tools/miri/cargo-miri" )
669+ }
670+
671+ fn make_run ( run : RunConfig < ' _ > ) {
672+ run. builder . ensure ( CargoMiri { target : run. target } ) ;
673+ }
674+
675+ /// Tests `cargo miri test`.
676+ fn run ( self , builder : & Builder < ' _ > ) {
677+ let host = builder. build . build ;
678+ let target = self . target ;
679+ let stage = builder. top_stage ;
680+ if stage == 0 {
681+ eprintln ! ( "cargo-miri cannot be tested at stage 0" ) ;
682+ std:: process:: exit ( 1 ) ;
683+ }
684+
685+ // This compiler runs on the host, we'll just use it for the target.
686+ let compiler = builder. compiler ( stage, host) ;
687+
688+ // Run `cargo miri test`.
657689 // This is just a smoke test (Miri's own CI invokes this in a bunch of different ways and ensures
658690 // that we get the desired output), but that is sufficient to make sure that the libtest harness
659691 // itself executes properly under Miri, and that all the logic in `cargo-miri` does not explode.
660- // This is running the build `cargo-miri` for the given target, so we need the target compiler.
661692 let mut cargo = tool:: prepare_tool_cargo (
662693 builder,
663- target_compiler ,
694+ compiler ,
664695 Mode :: ToolStd , // it's unclear what to use here, we're not building anything just doing a smoke test!
665696 target,
666697 "miri-test" ,
0 commit comments