@@ -597,7 +597,7 @@ impl Step for Miri {
597
597
builder. ensure ( compile:: Std :: new ( target_compiler, host) ) ;
598
598
let host_sysroot = builder. sysroot ( target_compiler) ;
599
599
600
- // # Run `cargo test`.
600
+ // Run `cargo test`.
601
601
// This is with the Miri crate, so it uses the host compiler.
602
602
let mut cargo = tool:: prepare_tool_cargo (
603
603
builder,
@@ -652,15 +652,46 @@ impl Step for Miri {
652
652
builder. run ( & mut cargo) ;
653
653
}
654
654
}
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 ;
655
666
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`.
657
689
// This is just a smoke test (Miri's own CI invokes this in a bunch of different ways and ensures
658
690
// that we get the desired output), but that is sufficient to make sure that the libtest harness
659
691
// 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.
661
692
let mut cargo = tool:: prepare_tool_cargo (
662
693
builder,
663
- target_compiler ,
694
+ compiler ,
664
695
Mode :: ToolStd , // it's unclear what to use here, we're not building anything just doing a smoke test!
665
696
target,
666
697
"miri-test" ,
0 commit comments