@@ -464,49 +464,14 @@ pub struct Miri {
464464 target : TargetSelection ,
465465}
466466
467- impl Step for Miri {
468- type Output = ( ) ;
469- const ONLY_HOSTS : bool = false ;
470-
471- fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
472- run. path ( "src/tools/miri" )
473- }
474-
475- fn make_run ( run : RunConfig < ' _ > ) {
476- run. builder . ensure ( Miri {
477- stage : run. builder . top_stage ,
478- host : run. build_triple ( ) ,
479- target : run. target ,
480- } ) ;
481- }
482-
483- /// Runs `cargo test` for miri.
484- fn run ( self , builder : & Builder < ' _ > ) {
485- let stage = self . stage ;
486- let host = self . host ;
487- let target = self . target ;
488- let compiler = builder. compiler ( stage, host) ;
489- // We need the stdlib for the *next* stage, as it was built with this compiler that also built Miri.
490- // Except if we are at stage 2, the bootstrap loop is complete and we can stick with our current stage.
491- let compiler_std = builder. compiler ( if stage < 2 { stage + 1 } else { stage } , host) ;
492-
493- let miri = builder
494- . ensure ( tool:: Miri { compiler, target : self . host , extra_features : Vec :: new ( ) } )
495- . expect ( "in-tree tool" ) ;
496- let _cargo_miri = builder
497- . ensure ( tool:: CargoMiri { compiler, target : self . host , extra_features : Vec :: new ( ) } )
498- . expect ( "in-tree tool" ) ;
499- // The stdlib we need might be at a different stage. And just asking for the
500- // sysroot does not seem to populate it, so we do that first.
501- builder. ensure ( compile:: Std :: new ( compiler_std, host) ) ;
502- let sysroot = builder. sysroot ( compiler_std) ;
503-
504- // # Run `cargo miri setup` for the given target.
467+ impl Miri {
468+ /// Run `cargo miri setup` for the given target, return where the Miri sysroot was put.
469+ pub fn build_miri_sysroot ( builder : & Builder < ' _ > , compiler : Compiler , miri : & Path , target : TargetSelection ) -> String {
505470 let mut cargo = tool:: prepare_tool_cargo (
506471 builder,
507472 compiler,
508473 Mode :: ToolRustc ,
509- host,
474+ compiler . host ,
510475 "run" ,
511476 "src/tools/miri/cargo-miri" ,
512477 SourceType :: InTree ,
@@ -534,7 +499,7 @@ impl Step for Miri {
534499 cargo. arg ( "--print-sysroot" ) ;
535500
536501 // FIXME: Is there a way in which we can re-use the usual `run` helpers?
537- let miri_sysroot = if builder. config . dry_run {
502+ if builder. config . dry_run {
538503 String :: new ( )
539504 } else {
540505 builder. verbose ( & format ! ( "running: {:?}" , cargo) ) ;
@@ -547,7 +512,48 @@ impl Step for Miri {
547512 let sysroot = stdout. trim_end ( ) ;
548513 builder. verbose ( & format ! ( "`cargo miri setup --print-sysroot` said: {:?}" , sysroot) ) ;
549514 sysroot. to_owned ( )
550- } ;
515+ }
516+ }
517+ }
518+
519+ impl Step for Miri {
520+ type Output = ( ) ;
521+ const ONLY_HOSTS : bool = false ;
522+
523+ fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
524+ run. path ( "src/tools/miri" )
525+ }
526+
527+ fn make_run ( run : RunConfig < ' _ > ) {
528+ run. builder . ensure ( Miri {
529+ stage : run. builder . top_stage ,
530+ host : run. build_triple ( ) ,
531+ target : run. target ,
532+ } ) ;
533+ }
534+
535+ /// Runs `cargo test` for miri.
536+ fn run ( self , builder : & Builder < ' _ > ) {
537+ let stage = self . stage ;
538+ let host = self . host ;
539+ let target = self . target ;
540+ let compiler = builder. compiler ( stage, host) ;
541+ // We need the stdlib for the *next* stage, as it was built with this compiler that also built Miri.
542+ // Except if we are at stage 2, the bootstrap loop is complete and we can stick with our current stage.
543+ let compiler_std = builder. compiler ( if stage < 2 { stage + 1 } else { stage } , host) ;
544+
545+ let miri = builder
546+ . ensure ( tool:: Miri { compiler, target : self . host , extra_features : Vec :: new ( ) } )
547+ . expect ( "in-tree tool" ) ;
548+ let _cargo_miri = builder
549+ . ensure ( tool:: CargoMiri { compiler, target : self . host , extra_features : Vec :: new ( ) } )
550+ . expect ( "in-tree tool" ) ;
551+ // The stdlib we need might be at a different stage. And just asking for the
552+ // sysroot does not seem to populate it, so we do that first.
553+ builder. ensure ( compile:: Std :: new ( compiler_std, host) ) ;
554+ let sysroot = builder. sysroot ( compiler_std) ;
555+ // We also need a Miri sysroot.
556+ let miri_sysroot = Miri :: build_miri_sysroot ( builder, compiler, & miri, target) ;
551557
552558 // # Run `cargo test`.
553559 let mut cargo = tool:: prepare_tool_cargo (
@@ -565,7 +571,6 @@ impl Step for Miri {
565571 // miri tests need to know about the stage sysroot
566572 cargo. env ( "MIRI_SYSROOT" , & miri_sysroot) ;
567573 cargo. env ( "MIRI_HOST_SYSROOT" , sysroot) ;
568- cargo. env ( "RUSTC_LIB_PATH" , builder. rustc_libdir ( compiler) ) ;
569574 cargo. env ( "MIRI" , & miri) ;
570575 // propagate --bless
571576 if builder. config . cmd . bless ( ) {
@@ -606,7 +611,6 @@ impl Step for Miri {
606611 // Tell `cargo miri` where to find things.
607612 cargo. env ( "MIRI_SYSROOT" , & miri_sysroot) ;
608613 cargo. env ( "MIRI_HOST_SYSROOT" , sysroot) ;
609- cargo. env ( "RUSTC_LIB_PATH" , builder. rustc_libdir ( compiler) ) ;
610614 cargo. env ( "MIRI" , & miri) ;
611615 // Debug things.
612616 cargo. env ( "RUST_BACKTRACE" , "1" ) ;
0 commit comments