@@ -441,7 +441,6 @@ impl Step for Std {
441441 t ! ( fs:: create_dir_all( & out) ) ;
442442 let compiler = builder. compiler ( stage, builder. config . build ) ;
443443
444- builder. ensure ( compile:: Std { compiler, target } ) ;
445444 let out_dir = builder. stage_out ( compiler, Mode :: Std ) . join ( target. triple ) . join ( "doc" ) ;
446445
447446 t ! ( fs:: copy( builder. src. join( "src/doc/rust.css" ) , out. join( "rust.css" ) ) ) ;
@@ -548,7 +547,6 @@ impl Step for Rustc {
548547 fn run ( self , builder : & Builder < ' _ > ) {
549548 let stage = self . stage ;
550549 let target = self . target ;
551- builder. info ( & format ! ( "Documenting stage{} compiler ({})" , stage, target) ) ;
552550
553551 let paths = builder
554552 . paths
@@ -563,9 +561,12 @@ impl Step for Rustc {
563561 let out = builder. compiler_doc_out ( target) ;
564562 t ! ( fs:: create_dir_all( & out) ) ;
565563
566- // Build rustc.
564+ // Build the standard library, so that proc-macros can use it.
565+ // (Normally, only the metadata would be necessary, but proc-macros are special since they run at compile-time.)
567566 let compiler = builder. compiler ( stage, builder. config . build ) ;
568- builder. ensure ( compile:: Rustc { compiler, target } ) ;
567+ builder. ensure ( compile:: Std { compiler, target : builder. config . build } ) ;
568+
569+ builder. info ( & format ! ( "Documenting stage{} compiler ({})" , stage, target) ) ;
569570
570571 // This uses a shared directory so that librustdoc documentation gets
571572 // correctly built and merged with the rustc documentation. This is
@@ -642,7 +643,6 @@ macro_rules! tool_doc {
642643 ( $tool: ident, $should_run: literal, $path: literal, [ $( $krate: literal) ,+ $( , ) ?] $( , ) ?) => {
643644 #[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
644645 pub struct $tool {
645- stage: u32 ,
646646 target: TargetSelection ,
647647 }
648648
@@ -657,7 +657,7 @@ macro_rules! tool_doc {
657657 }
658658
659659 fn make_run( run: RunConfig <' _>) {
660- run. builder. ensure( $tool { stage : run . builder . top_stage , target: run. target } ) ;
660+ run. builder. ensure( $tool { target: run. target } ) ;
661661 }
662662
663663 /// Generates compiler documentation.
@@ -667,8 +667,21 @@ macro_rules! tool_doc {
667667 /// we do not merge it with the other documentation from std, test and
668668 /// proc_macros. This is largely just a wrapper around `cargo doc`.
669669 fn run( self , builder: & Builder <' _>) {
670- let stage = self . stage ;
670+ let stage = builder . top_stage ;
671671 let target = self . target;
672+
673+ // This is the intended out directory for compiler documentation.
674+ let out = builder. compiler_doc_out( target) ;
675+ t!( fs:: create_dir_all( & out) ) ;
676+
677+ // Build rustc docs so that we generate relative links.
678+ builder. ensure( Rustc { stage, target } ) ;
679+ // Rustdoc needs the rustc sysroot available to build.
680+ // FIXME: is there a way to only ensure `check::Rustc` here? Last time I tried it failed
681+ // with strange errors, but only on a full bors test ...
682+ let compiler = builder. compiler( stage, builder. config. build) ;
683+ builder. ensure( compile:: Rustc { compiler, target } ) ;
684+
672685 builder. info(
673686 & format!(
674687 "Documenting stage{} {} ({})" ,
@@ -678,15 +691,6 @@ macro_rules! tool_doc {
678691 ) ,
679692 ) ;
680693
681- // This is the intended out directory for compiler documentation.
682- let out = builder. compiler_doc_out( target) ;
683- t!( fs:: create_dir_all( & out) ) ;
684-
685- let compiler = builder. compiler( stage, builder. config. build) ;
686-
687- // Build rustc docs so that we generate relative links.
688- builder. ensure( Rustc { stage, target } ) ;
689-
690694 // Symlink compiler docs to the output directory of rustdoc documentation.
691695 let out_dir = builder. stage_out( compiler, Mode :: ToolRustc ) . join( target. triple) . join( "doc" ) ;
692696 t!( fs:: create_dir_all( & out_dir) ) ;
0 commit comments