@@ -453,12 +453,14 @@ macro_rules! tool_check_step {
453
453
// The part of this path after the final '/' is also used as a display name.
454
454
path: $path: literal
455
455
$( , alt_path: $alt_path: literal ) *
456
+ , mode: $mode: path
456
457
$( , default : $default: literal ) ?
457
458
$( , ) ?
458
459
}
459
460
) => {
460
461
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
461
462
pub struct $name {
463
+ pub build_compiler: Compiler ,
462
464
pub target: TargetSelection ,
463
465
}
464
466
@@ -473,16 +475,33 @@ macro_rules! tool_check_step {
473
475
}
474
476
475
477
fn make_run( run: RunConfig <' _>) {
476
- run. builder. ensure( $name { target: run. target } ) ;
478
+ let host = run. builder. config. host_target;
479
+ let target = run. target;
480
+ let build_compiler = match $mode {
481
+ Mode :: ToolBootstrap => run. builder. compiler( 0 , host) ,
482
+ Mode :: ToolStd => {
483
+ // A small number of tools rely on in-tree standard
484
+ // library crates (e.g. compiletest needs libtest).
485
+ let build_compiler = run. builder. compiler( run. builder. top_stage, host) ;
486
+ run. builder. std( build_compiler, host) ;
487
+ run. builder. std( build_compiler, target) ;
488
+ build_compiler
489
+ }
490
+ Mode :: ToolRustc => {
491
+ prepare_compiler_for_tool_rustc( run. builder, target)
492
+ }
493
+ _ => panic!( "unexpected mode for tool check step: {:?}" , $mode) ,
494
+ } ;
495
+ run. builder. ensure( $name { target, build_compiler } ) ;
477
496
}
478
497
479
498
fn run( self , builder: & Builder <' _>) {
480
- let Self { target } = self ;
481
- run_tool_check_step( builder, target, stringify! ( $name ) , $path ) ;
499
+ let Self { target, build_compiler } = self ;
500
+ run_tool_check_step( builder, build_compiler , target, $path , $mode ) ;
482
501
}
483
502
484
503
fn metadata( & self ) -> Option <StepMetadata > {
485
- Some ( StepMetadata :: check( stringify!( $name) , self . target) )
504
+ Some ( StepMetadata :: check( stringify!( $name) , self . target) . built_by ( self . build_compiler ) )
486
505
}
487
506
}
488
507
}
@@ -491,19 +510,17 @@ macro_rules! tool_check_step {
491
510
/// Used by the implementation of `Step::run` in `tool_check_step!`.
492
511
fn run_tool_check_step (
493
512
builder : & Builder < ' _ > ,
513
+ build_compiler : Compiler ,
494
514
target : TargetSelection ,
495
- step_type_name : & str ,
496
515
path : & str ,
516
+ mode : Mode ,
497
517
) {
498
518
let display_name = path. rsplit ( '/' ) . next ( ) . unwrap ( ) ;
499
- let compiler = builder. compiler ( builder. top_stage , builder. config . host_target ) ;
500
-
501
- builder. ensure ( Rustc :: new ( builder, compiler, target) ) ;
502
519
503
520
let mut cargo = prepare_tool_cargo (
504
521
builder,
505
- compiler ,
506
- Mode :: ToolRustc ,
522
+ build_compiler ,
523
+ mode ,
507
524
target,
508
525
builder. kind ,
509
526
path,
@@ -515,33 +532,56 @@ fn run_tool_check_step(
515
532
& [ ] ,
516
533
) ;
517
534
535
+ // FIXME: check bootstrap doesn't currently work with --all-targets
518
536
cargo. arg ( "--all-targets" ) ;
519
537
520
- let stamp = BuildStamp :: new ( & builder. cargo_out ( compiler, Mode :: ToolRustc , target) )
521
- . with_prefix ( & format ! ( "{}-check" , step_type_name. to_lowercase( ) ) ) ;
538
+ let stamp = BuildStamp :: new ( & builder. cargo_out ( build_compiler, mode, target) )
539
+ . with_prefix ( & format ! ( "{display_name}-check" ) ) ;
540
+
541
+ let stage = match mode {
542
+ // Mode::ToolRustc is included here because of how msg_sysroot_tool prints stages
543
+ Mode :: Std | Mode :: ToolRustc => build_compiler. stage ,
544
+ _ => build_compiler. stage + 1 ,
545
+ } ;
522
546
523
- let _guard = builder. msg_check ( format ! ( "{display_name} artifacts" ) , target, None ) ;
547
+ let _guard =
548
+ builder. msg_tool ( builder. kind , mode, display_name, stage, & build_compiler. host , & target) ;
524
549
run_cargo ( builder, cargo, builder. config . free_args . clone ( ) , & stamp, vec ! [ ] , true , false ) ;
525
550
}
526
551
527
- tool_check_step ! ( Rustdoc { path: "src/tools/rustdoc" , alt_path: "src/librustdoc" } ) ;
552
+ tool_check_step ! ( Rustdoc {
553
+ path: "src/tools/rustdoc" ,
554
+ alt_path: "src/librustdoc" ,
555
+ mode: Mode :: ToolRustc
556
+ } ) ;
528
557
// Clippy, miri and Rustfmt are hybrids. They are external tools, but use a git subtree instead
529
558
// of a submodule. Since the SourceType only drives the deny-warnings
530
559
// behavior, treat it as in-tree so that any new warnings in clippy will be
531
560
// rejected.
532
- tool_check_step ! ( Clippy { path: "src/tools/clippy" } ) ;
533
- tool_check_step ! ( Miri { path: "src/tools/miri" } ) ;
534
- tool_check_step ! ( CargoMiri { path: "src/tools/miri/cargo-miri" } ) ;
535
- tool_check_step ! ( Rustfmt { path: "src/tools/rustfmt" } ) ;
536
- tool_check_step ! ( MiroptTestTools { path: "src/tools/miropt-test-tools" } ) ;
537
- tool_check_step ! ( TestFloatParse { path: "src/tools/test-float-parse" } ) ;
538
- tool_check_step ! ( FeaturesStatusDump { path: "src/tools/features-status-dump" } ) ;
539
-
540
- tool_check_step ! ( Bootstrap { path: "src/bootstrap" , default : false } ) ;
561
+ tool_check_step ! ( Clippy { path: "src/tools/clippy" , mode: Mode :: ToolRustc } ) ;
562
+ tool_check_step ! ( Miri { path: "src/tools/miri" , mode: Mode :: ToolRustc } ) ;
563
+ tool_check_step ! ( CargoMiri { path: "src/tools/miri/cargo-miri" , mode: Mode :: ToolRustc } ) ;
564
+ tool_check_step ! ( Rustfmt { path: "src/tools/rustfmt" , mode: Mode :: ToolRustc } ) ;
565
+ tool_check_step ! ( MiroptTestTools {
566
+ path: "src/tools/miropt-test-tools" ,
567
+ mode: Mode :: ToolBootstrap
568
+ } ) ;
569
+ // We want to test the local std
570
+ tool_check_step ! ( TestFloatParse { path: "src/tools/test-float-parse" , mode: Mode :: ToolStd } ) ;
571
+ tool_check_step ! ( FeaturesStatusDump {
572
+ path: "src/tools/features-status-dump" ,
573
+ mode: Mode :: ToolBootstrap
574
+ } ) ;
575
+
576
+ tool_check_step ! ( Bootstrap { path: "src/bootstrap" , mode: Mode :: ToolBootstrap , default : false } ) ;
541
577
542
578
// `run-make-support` will be built as part of suitable run-make compiletest test steps, but support
543
579
// check to make it easier to work on.
544
- tool_check_step ! ( RunMakeSupport { path: "src/tools/run-make-support" , default : false } ) ;
580
+ tool_check_step ! ( RunMakeSupport {
581
+ path: "src/tools/run-make-support" ,
582
+ mode: Mode :: ToolBootstrap ,
583
+ default : false
584
+ } ) ;
545
585
546
586
/// Check step for the `coverage-dump` bootstrap tool. The coverage-dump tool
547
587
/// is used internally by coverage tests.
0 commit comments