Skip to content

Commit 39f93a2

Browse files
Stop utilizing stage 1 for doc building if stage 2 is asked
There's no reason to prefer stage 1 when building docs
1 parent ce08a72 commit 39f93a2

File tree

2 files changed

+19
-45
lines changed

2 files changed

+19
-45
lines changed

src/bootstrap/doc.rs

+19-35
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@ use crate::compile;
2222
use crate::cache::{INTERNER, Interned};
2323
use crate::config::Config;
2424

25+
fn doc_dir(
26+
builder: &Builder<'_>,
27+
compiler: Compiler,
28+
target: Interned<String>,
29+
mode: Mode,
30+
) -> PathBuf {
31+
let compiler = if builder.force_use_stage1(compiler, target) {
32+
builder.compiler(1, compiler.host)
33+
} else {
34+
compiler
35+
};
36+
builder.stage_out(compiler, mode).join(target).join("doc")
37+
}
38+
2539
macro_rules! book {
2640
($($name:ident, $path:expr, $book_name:expr, $book_ver:expr;)+) => {
2741
$(
@@ -476,15 +490,9 @@ impl Step for Std {
476490
let out = builder.doc_out(target);
477491
t!(fs::create_dir_all(&out));
478492
let compiler = builder.compiler(stage, builder.config.build);
479-
let compiler = if builder.force_use_stage1(compiler, target) {
480-
builder.compiler(1, compiler.host)
481-
} else {
482-
compiler
483-
};
484493

485494
builder.ensure(compile::Std { compiler, target });
486-
let out_dir = builder.stage_out(compiler, Mode::Std)
487-
.join(target).join("doc");
495+
let out_dir = doc_dir(builder, compiler, target, Mode::Std);
488496

489497
// Here what we're doing is creating a *symlink* (directory junction on
490498
// Windows) to the final output location. This is not done as an
@@ -564,18 +572,12 @@ impl Step for Test {
564572
let out = builder.doc_out(target);
565573
t!(fs::create_dir_all(&out));
566574
let compiler = builder.compiler(stage, builder.config.build);
567-
let compiler = if builder.force_use_stage1(compiler, target) {
568-
builder.compiler(1, compiler.host)
569-
} else {
570-
compiler
571-
};
572575

573576
// Build libstd docs so that we generate relative links
574577
builder.ensure(Std { stage, target });
575578

576579
builder.ensure(compile::Test { compiler, target });
577-
let out_dir = builder.stage_out(compiler, Mode::Test)
578-
.join(target).join("doc");
580+
let out_dir = doc_dir(builder, compiler, target, Mode::Test);
579581

580582
// See docs in std above for why we symlink
581583
let my_out = builder.crate_doc_out(target);
@@ -633,18 +635,12 @@ impl Step for WhitelistedRustc {
633635
let out = builder.doc_out(target);
634636
t!(fs::create_dir_all(&out));
635637
let compiler = builder.compiler(stage, builder.config.build);
636-
let compiler = if builder.force_use_stage1(compiler, target) {
637-
builder.compiler(1, compiler.host)
638-
} else {
639-
compiler
640-
};
641638

642639
// Build libstd docs so that we generate relative links
643640
builder.ensure(Std { stage, target });
644641

645642
builder.ensure(compile::Rustc { compiler, target });
646-
let out_dir = builder.stage_out(compiler, Mode::Rustc)
647-
.join(target).join("doc");
643+
let out_dir = doc_dir(builder, compiler, target, Mode::Rustc);
648644

649645
// See docs in std above for why we symlink
650646
let my_out = builder.crate_doc_out(target);
@@ -707,11 +703,6 @@ impl Step for Rustc {
707703

708704
// Get the correct compiler for this stage.
709705
let compiler = builder.compiler(stage, builder.config.build);
710-
let compiler = if builder.force_use_stage1(compiler, target) {
711-
builder.compiler(1, compiler.host)
712-
} else {
713-
compiler
714-
};
715706

716707
if !builder.config.compiler_docs {
717708
builder.info("\tskipping - compiler/librustdoc docs disabled");
@@ -723,7 +714,7 @@ impl Step for Rustc {
723714

724715
// We do not symlink to the same shared folder that already contains std library
725716
// documentation from previous steps as we do not want to include that.
726-
let out_dir = builder.stage_out(compiler, Mode::Rustc).join(target).join("doc");
717+
let out_dir = doc_dir(builder, compiler, target, Mode::Rustc);
727718
t!(symlink_dir_force(&builder.config, &out, &out_dir));
728719

729720
// Build cargo command.
@@ -808,11 +799,6 @@ impl Step for Rustdoc {
808799

809800
// Get the correct compiler for this stage.
810801
let compiler = builder.compiler(stage, builder.config.build);
811-
let compiler = if builder.force_use_stage1(compiler, target) {
812-
builder.compiler(1, compiler.host)
813-
} else {
814-
compiler
815-
};
816802

817803
if !builder.config.compiler_docs {
818804
builder.info("\tskipping - compiler/librustdoc docs disabled");
@@ -826,9 +812,7 @@ impl Step for Rustdoc {
826812
builder.ensure(tool::Rustdoc { compiler: compiler });
827813

828814
// Symlink compiler docs to the output directory of rustdoc documentation.
829-
let out_dir = builder.stage_out(compiler, Mode::ToolRustc)
830-
.join(target)
831-
.join("doc");
815+
let out_dir = doc_dir(builder, compiler, target, Mode::ToolRustc);
832816
t!(fs::create_dir_all(&out_dir));
833817
t!(symlink_dir_force(&builder.config, &out, &out_dir));
834818

src/bootstrap/test.rs

-10
Original file line numberDiff line numberDiff line change
@@ -1678,16 +1678,6 @@ impl Step for Crate {
16781678
builder.ensure(compile::Test { compiler, target });
16791679
builder.ensure(RemoteCopyLibs { compiler, target });
16801680

1681-
// If we're not doing a full bootstrap but we're testing a stage2 version of
1682-
// libstd, then what we're actually testing is the libstd produced in
1683-
// stage1. Reflect that here by updating the compiler that we're working
1684-
// with automatically.
1685-
let compiler = if builder.force_use_stage1(compiler, target) {
1686-
builder.compiler(1, compiler.host)
1687-
} else {
1688-
compiler.clone()
1689-
};
1690-
16911681
let mut cargo = builder.cargo(compiler, mode, target, test_kind.subcommand());
16921682
match mode {
16931683
Mode::Std => {

0 commit comments

Comments
 (0)