@@ -527,3 +527,70 @@ tool_check_step!(Bootstrap { path: "src/bootstrap", default: false });
527527// `run-make-support` will be built as part of suitable run-make compiletest test steps, but support
528528// check to make it easier to work on.
529529tool_check_step ! ( RunMakeSupport { path: "src/tools/run-make-support" , default : false } ) ;
530+
531+ /// Check step for the `coverage-dump` bootstrap tool. The coverage-dump tool
532+ /// is used internally by coverage tests.
533+ ///
534+ /// FIXME(Zalathar): This is temporarily separate from the other tool check
535+ /// steps so that it can use the stage 0 compiler instead of `top_stage`,
536+ /// without introducing conflicts with the stage 0 redesign (#119899).
537+ ///
538+ /// After the stage 0 redesign lands, we can look into using the stage 0
539+ /// compiler to check all bootstrap tools (#139170).
540+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
541+ pub ( crate ) struct CoverageDump ;
542+
543+ impl CoverageDump {
544+ const PATH : & str = "src/tools/coverage-dump" ;
545+ }
546+
547+ impl Step for CoverageDump {
548+ type Output = ( ) ;
549+
550+ /// Most contributors won't care about coverage-dump, so don't make their
551+ /// check builds slower unless they opt in and check it explicitly.
552+ const DEFAULT : bool = false ;
553+ const ONLY_HOSTS : bool = true ;
554+
555+ fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
556+ run. path ( Self :: PATH )
557+ }
558+
559+ fn make_run ( run : RunConfig < ' _ > ) {
560+ run. builder . ensure ( Self { } ) ;
561+ }
562+
563+ fn run ( self , builder : & Builder < ' _ > ) -> Self :: Output {
564+ // Make sure we haven't forgotten any fields, if there are any.
565+ let Self { } = self ;
566+ let display_name = "coverage-dump" ;
567+ let host = builder. config . build ;
568+ let target = host;
569+ let mode = Mode :: ToolBootstrap ;
570+
571+ let compiler = builder. compiler ( 0 , host) ;
572+ let cargo = prepare_tool_cargo (
573+ builder,
574+ compiler,
575+ mode,
576+ target,
577+ builder. kind ,
578+ Self :: PATH ,
579+ SourceType :: InTree ,
580+ & [ ] ,
581+ ) ;
582+
583+ let stamp = BuildStamp :: new ( & builder. cargo_out ( compiler, mode, target) )
584+ . with_prefix ( & format ! ( "{display_name}-check" ) ) ;
585+
586+ let _guard = builder. msg_tool (
587+ builder. kind ,
588+ mode,
589+ display_name,
590+ compiler. stage ,
591+ & compiler. host ,
592+ & target,
593+ ) ;
594+ run_cargo ( builder, cargo, builder. config . free_args . clone ( ) , & stamp, vec ! [ ] , true , false ) ;
595+ }
596+ }
0 commit comments