@@ -500,27 +500,46 @@ impl Miri {
500
500
/// Run `cargo miri setup` for the given target, return where the Miri sysroot was put.
501
501
pub fn build_miri_sysroot (
502
502
builder : & Builder < ' _ > ,
503
- compiler : Compiler ,
503
+ host_compiler : Compiler ,
504
504
target : TargetSelection ,
505
505
) -> String {
506
- let miri_sysroot = builder. out . join ( compiler. host . triple ) . join ( "miri-sysroot" ) ;
507
- let mut cargo = builder:: Cargo :: new (
506
+ let miri = builder. ensure ( tool:: Miri {
507
+ compiler : host_compiler,
508
+ target : host_compiler. host ,
509
+ extra_features : Vec :: new ( ) ,
510
+ } ) ;
511
+ let miri_sysroot = builder. out . join ( host_compiler. host . triple ) . join ( "miri-sysroot" ) ;
512
+ let mut cargo = tool:: prepare_tool_cargo (
508
513
builder,
509
- compiler,
510
- Mode :: Std ,
511
- SourceType :: Submodule ,
512
- target,
513
- "miri-setup" ,
514
+ host_compiler,
515
+ Mode :: ToolRustc ,
516
+ host_compiler. host ,
517
+ "run" ,
518
+ "src/tools/miri/cargo-miri" ,
519
+ SourceType :: InTree ,
520
+ & [ ] ,
514
521
) ;
522
+ cargo. add_rustc_lib_path ( builder) ;
523
+ cargo. arg ( "--" ) . arg ( "miri" ) . arg ( "setup" ) ;
524
+ cargo. arg ( "--target" ) . arg ( target. rustc_target_arg ( ) ) ;
515
525
516
526
// Tell `cargo miri setup` where to find the sources.
517
527
cargo. env ( "MIRI_LIB_SRC" , builder. src . join ( "library" ) ) ;
528
+ // Tell it where to find Miri.
529
+ cargo. env ( "MIRI" , miri) ;
518
530
// Tell it where to put the sysroot.
519
531
cargo. env ( "MIRI_SYSROOT" , & miri_sysroot) ;
532
+ // Debug things.
533
+ cargo. env ( "RUST_BACKTRACE" , "1" ) ;
520
534
521
535
let mut cargo = Command :: from ( cargo) ;
522
- let _guard =
523
- builder. msg ( Kind :: Build , compiler. stage , "miri sysroot" , compiler. host , target) ;
536
+ let _guard = builder. msg (
537
+ Kind :: Build ,
538
+ host_compiler. stage + 1 ,
539
+ "miri sysroot" ,
540
+ host_compiler. host ,
541
+ host_compiler. host ,
542
+ ) ;
524
543
builder. run ( & mut cargo) ;
525
544
526
545
// # Determine where Miri put its sysroot.
@@ -593,7 +612,7 @@ impl Step for Miri {
593
612
594
613
// We also need sysroots, for Miri and for the host (the latter for build scripts).
595
614
// This is for the tests so everything is done with the target compiler.
596
- let miri_sysroot = Miri :: build_miri_sysroot ( builder, target_compiler , target) ;
615
+ let miri_sysroot = Miri :: build_miri_sysroot ( builder, host_compiler , target) ;
597
616
builder. ensure ( compile:: Std :: new ( target_compiler, host) ) ;
598
617
let sysroot = builder. sysroot ( target_compiler) ;
599
618
0 commit comments