@@ -493,7 +493,6 @@ impl Step for RustDemangler {
493
493
494
494
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
495
495
pub struct Miri {
496
- stage : u32 ,
497
496
host : TargetSelection ,
498
497
target : TargetSelection ,
499
498
}
@@ -502,29 +501,21 @@ impl Miri {
502
501
/// Run `cargo miri setup` for the given target, return where the Miri sysroot was put.
503
502
pub fn build_miri_sysroot (
504
503
builder : & Builder < ' _ > ,
505
- compiler : Compiler ,
506
- miri : & Path ,
504
+ compiler_std : Compiler ,
507
505
target : TargetSelection ,
508
506
) -> String {
509
- let miri_sysroot = builder. out . join ( compiler . host . triple ) . join ( "miri-sysroot" ) ;
510
- let mut cargo = tool :: prepare_tool_cargo (
507
+ let miri_sysroot = builder. out . join ( compiler_std . host . triple ) . join ( "miri-sysroot" ) ;
508
+ let mut cargo = builder :: Cargo :: new (
511
509
builder,
512
- compiler,
513
- Mode :: ToolRustc ,
514
- compiler. host ,
515
- "run" ,
516
- "src/tools/miri/cargo-miri" ,
517
- SourceType :: InTree ,
518
- & [ ] ,
510
+ compiler_std, // this is compiler+1; cargo_miri_cmd will do -1 again
511
+ Mode :: Std ,
512
+ SourceType :: Submodule ,
513
+ target,
514
+ "miri-setup" ,
519
515
) ;
520
- cargo. add_rustc_lib_path ( builder) ;
521
- cargo. arg ( "--" ) . arg ( "miri" ) . arg ( "setup" ) ;
522
- cargo. arg ( "--target" ) . arg ( target. rustc_target_arg ( ) ) ;
523
516
524
517
// Tell `cargo miri setup` where to find the sources.
525
518
cargo. env ( "MIRI_LIB_SRC" , builder. src . join ( "library" ) ) ;
526
- // Tell it where to find Miri.
527
- cargo. env ( "MIRI" , miri) ;
528
519
// Tell it where to put the sysroot.
529
520
cargo. env ( "MIRI_SYSROOT" , & miri_sysroot) ;
530
521
// Debug things.
@@ -533,10 +524,10 @@ impl Miri {
533
524
let mut cargo = Command :: from ( cargo) ;
534
525
let _guard = builder. msg (
535
526
Kind :: Build ,
536
- compiler . stage + 1 ,
527
+ compiler_std . stage ,
537
528
"miri sysroot" ,
538
- compiler . host ,
539
- compiler . host ,
529
+ compiler_std . host ,
530
+ compiler_std . host ,
540
531
) ;
541
532
builder. run ( & mut cargo) ;
542
533
@@ -574,16 +565,12 @@ impl Step for Miri {
574
565
}
575
566
576
567
fn make_run ( run : RunConfig < ' _ > ) {
577
- run. builder . ensure ( Miri {
578
- stage : run. builder . top_stage ,
579
- host : run. build_triple ( ) ,
580
- target : run. target ,
581
- } ) ;
568
+ run. builder . ensure ( Miri { host : run. build_triple ( ) , target : run. target } ) ;
582
569
}
583
570
584
571
/// Runs `cargo test` for miri.
585
572
fn run ( self , builder : & Builder < ' _ > ) {
586
- let stage = self . stage ;
573
+ let stage = builder . top_stage ;
587
574
let host = self . host ;
588
575
let target = self . target ;
589
576
let compiler = builder. compiler ( stage, host) ;
@@ -592,18 +579,15 @@ impl Step for Miri {
592
579
let compiler_std = builder. compiler ( if stage < 2 { stage + 1 } else { stage } , host) ;
593
580
594
581
let miri =
595
- builder. ensure ( tool:: Miri { compiler, target : self . host , extra_features : Vec :: new ( ) } ) ;
596
- let _cargo_miri = builder. ensure ( tool:: CargoMiri {
597
- compiler,
598
- target : self . host ,
599
- extra_features : Vec :: new ( ) ,
600
- } ) ;
582
+ builder. ensure ( tool:: Miri { compiler, target : host, extra_features : Vec :: new ( ) } ) ;
583
+ // the ui tests also assume cargo-miri has been built
584
+ builder. ensure ( tool:: CargoMiri { compiler, target : host, extra_features : Vec :: new ( ) } ) ;
601
585
// The stdlib we need might be at a different stage. And just asking for the
602
586
// sysroot does not seem to populate it, so we do that first.
603
587
builder. ensure ( compile:: Std :: new ( compiler_std, host) ) ;
604
588
let sysroot = builder. sysroot ( compiler_std) ;
605
589
// We also need a Miri sysroot.
606
- let miri_sysroot = Miri :: build_miri_sysroot ( builder, compiler , & miri , target) ;
590
+ let miri_sysroot = Miri :: build_miri_sysroot ( builder, compiler_std , target) ;
607
591
608
592
// # Run `cargo test`.
609
593
let mut cargo = tool:: prepare_tool_cargo (
@@ -632,8 +616,8 @@ impl Step for Miri {
632
616
// Set the target.
633
617
cargo. env ( "MIRI_TEST_TARGET" , target. rustc_target_arg ( ) ) ;
634
618
635
- // This can NOT be `run_cargo_test` since the Miri test runner
636
- // does not understand the flags added by `add_flags_and_try_run_test`.
619
+ // This can NOT be `run_cargo_test` since Miri's integration tests do not use the usual test
620
+ // harness and therefore do not understand the flags added by `add_flags_and_try_run_test`.
637
621
let mut cargo = prepare_cargo_test ( cargo, & [ ] , & [ ] , "miri" , compiler, target, builder) ;
638
622
{
639
623
let _time = helpers:: timeit ( builder) ;
@@ -660,28 +644,20 @@ impl Step for Miri {
660
644
// # Run `cargo miri test`.
661
645
// This is just a smoke test (Miri's own CI invokes this in a bunch of different ways and ensures
662
646
// that we get the desired output), but that is sufficient to make sure that the libtest harness
663
- // itself executes properly under Miri.
647
+ // itself executes properly under Miri, and that all the logic in `cargo-miri` does not explode.
648
+ // Everything here needs `compiler_std` to be actually testing the Miri in the current stage.
664
649
let mut cargo = tool:: prepare_tool_cargo (
665
650
builder,
666
- compiler ,
667
- Mode :: ToolRustc ,
668
- host ,
669
- "run " ,
670
- "src/tools/miri/cargo-miri" ,
651
+ compiler_std , // this is compiler+1; cargo_miri_cmd will do -1 again
652
+ Mode :: ToolStd , // it's unclear what to use here, we're not building anything just doing a smoke test!
653
+ target ,
654
+ "miri-test " ,
655
+ "src/tools/miri/test- cargo-miri" ,
671
656
SourceType :: Submodule ,
672
657
& [ ] ,
673
658
) ;
674
- cargo. add_rustc_lib_path ( builder) ;
675
- cargo. arg ( "--" ) . arg ( "miri" ) . arg ( "test" ) ;
676
- if builder. config . locked_deps {
677
- cargo. arg ( "--locked" ) ;
678
- }
679
- cargo
680
- . arg ( "--manifest-path" )
681
- . arg ( builder. src . join ( "src/tools/miri/test-cargo-miri/Cargo.toml" ) ) ;
682
- cargo. arg ( "--target" ) . arg ( target. rustc_target_arg ( ) ) ;
683
659
684
- // `prepare_tool_cargo` sets RUSTDOC to the bootstrap wrapper and RUSTDOC_REAL to a dummy path as this is a "run ", not a "test".
660
+ // `prepare_tool_cargo` sets RUSTDOC to the bootstrap wrapper and RUSTDOC_REAL to a dummy path as this is a "miri ", not a "test".
685
661
// Also, we want the rustdoc from the "next" stage for the same reason that we build a std from the next stage.
686
662
// So let's just set that here, and bypass bootstrap's RUSTDOC (just like cargo-miri already ignores bootstrap's RUSTC_WRAPPER).
687
663
if builder. doc_tests != DocTests :: No {
@@ -697,10 +673,9 @@ impl Step for Miri {
697
673
}
698
674
}
699
675
700
- // Tell `cargo miri` where to find things .
676
+ // Tell `cargo miri` where to find the sysroots .
701
677
cargo. env ( "MIRI_SYSROOT" , & miri_sysroot) ;
702
678
cargo. env ( "MIRI_HOST_SYSROOT" , sysroot) ;
703
- cargo. env ( "MIRI" , & miri) ;
704
679
// Debug things.
705
680
cargo. env ( "RUST_BACKTRACE" , "1" ) ;
706
681
0 commit comments