Skip to content

Commit 7543293

Browse files
committed
Don't build the library and standard library before documenting them
Rustdoc doesn't require the build artifacts to generate the docs, and especially in the case of rustc, it greatly increases the time needed to run the build.
1 parent 3e8f32e commit 7543293

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/bootstrap/check.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ fn cargo_subcommand(kind: Kind) -> &'static str {
5555
Kind::Check => "check",
5656
Kind::Clippy => "clippy",
5757
Kind::Fix => "fix",
58-
_ => unreachable!(),
58+
// Another top-level command is calling check
59+
_ => "check",
5960
}
6061
}
6162

src/bootstrap/doc.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use build_helper::{t, up_to_date};
1717

1818
use crate::builder::{Builder, Compiler, RunConfig, ShouldRun, Step};
1919
use crate::cache::{Interned, INTERNER};
20+
use crate::check;
2021
use crate::compile;
2122
use crate::config::{Config, TargetSelection};
2223
use crate::tool::{self, prepare_tool_cargo, SourceType, Tool};
@@ -438,7 +439,6 @@ impl Step for Std {
438439
t!(fs::create_dir_all(&out));
439440
let compiler = builder.compiler(stage, builder.config.build);
440441

441-
builder.ensure(compile::Std { compiler, target });
442442
let out_dir = builder.stage_out(compiler, Mode::Std).join(target.triple).join("doc");
443443

444444
t!(fs::copy(builder.src.join("src/doc/rust.css"), out.join("rust.css")));
@@ -569,9 +569,10 @@ impl Step for Rustc {
569569
let out = builder.compiler_doc_out(target);
570570
t!(fs::create_dir_all(&out));
571571

572-
// Build rustc.
572+
// Build the standard library, so that proc-macros can use it.
573+
// (Normally, only the metadata would be necessary, but proc-macros are special since they run at compile-time.)
573574
let compiler = builder.compiler(stage, builder.config.build);
574-
builder.ensure(compile::Rustc { compiler, target });
575+
builder.ensure(compile::Std { compiler, target: builder.config.build });
575576

576577
// This uses a shared directory so that librustdoc documentation gets
577578
// correctly built and merged with the rustc documentation. This is
@@ -699,21 +700,22 @@ macro_rules! tool_doc {
699700
),
700701
);
701702

702-
// This is the intended out directory for compiler documentation.
703-
let out = builder.compiler_doc_out(target);
704-
t!(fs::create_dir_all(&out));
705-
706-
let compiler = builder.compiler(stage, builder.config.build);
707-
708703
if !builder.config.compiler_docs && !builder.was_invoked_explicitly::<Self>() {
709704
builder.info("\tskipping - compiler/tool docs disabled");
710705
return;
711706
}
712707

708+
// This is the intended out directory for compiler documentation.
709+
let out = builder.compiler_doc_out(target);
710+
t!(fs::create_dir_all(&out));
711+
713712
// Build rustc docs so that we generate relative links.
714713
builder.ensure(Rustc { stage, target });
714+
// Rustdoc needs the rustc sysroot available to build.
715+
builder.ensure(check::Rustc { target });
715716

716717
// Symlink compiler docs to the output directory of rustdoc documentation.
718+
let compiler = builder.compiler(stage, builder.config.build);
717719
let out_dir = builder.stage_out(compiler, Mode::ToolRustc).join(target.triple).join("doc");
718720
t!(fs::create_dir_all(&out_dir));
719721
t!(symlink_dir_force(&builder.config, &out, &out_dir));

0 commit comments

Comments
 (0)