Skip to content

Commit 03718ed

Browse files
Permit getting stage 0 rustdoc
This allows us to e.g. test compiletest, including doctests, in stage 0 without building a fresh compiler and rustdoc.
1 parent 9efc93c commit 03718ed

File tree

5 files changed

+21
-20
lines changed

5 files changed

+21
-20
lines changed

src/bootstrap/builder.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -668,28 +668,27 @@ impl<'a> Builder<'a> {
668668
.map(|entry| entry.path())
669669
}
670670

671-
pub fn rustdoc(&self, host: Interned<String>) -> PathBuf {
672-
self.ensure(tool::Rustdoc { host })
671+
pub fn rustdoc(&self, compiler: Compiler) -> PathBuf {
672+
self.ensure(tool::Rustdoc { compiler })
673673
}
674674

675-
pub fn rustdoc_cmd(&self, host: Interned<String>) -> Command {
675+
pub fn rustdoc_cmd(&self, compiler: Compiler) -> Command {
676676
let mut cmd = Command::new(&self.out.join("bootstrap/debug/rustdoc"));
677-
let compiler = self.compiler(self.top_stage, host);
678677
cmd.env("RUSTC_STAGE", compiler.stage.to_string())
679678
.env("RUSTC_SYSROOT", self.sysroot(compiler))
680679
// Note that this is *not* the sysroot_libdir because rustdoc must be linked
681680
// equivalently to rustc.
682681
.env("RUSTDOC_LIBDIR", self.rustc_libdir(compiler))
683682
.env("CFG_RELEASE_CHANNEL", &self.config.channel)
684-
.env("RUSTDOC_REAL", self.rustdoc(host))
683+
.env("RUSTDOC_REAL", self.rustdoc(compiler))
685684
.env("RUSTDOC_CRATE_VERSION", self.rust_version())
686685
.env("RUSTC_BOOTSTRAP", "1");
687686

688687
// Remove make-related flags that can cause jobserver problems.
689688
cmd.env_remove("MAKEFLAGS");
690689
cmd.env_remove("MFLAGS");
691690

692-
if let Some(linker) = self.linker(host) {
691+
if let Some(linker) = self.linker(compiler.host) {
693692
cmd.env("RUSTC_TARGET_LINKER", linker);
694693
}
695694
cmd
@@ -751,7 +750,7 @@ impl<'a> Builder<'a> {
751750
// This is the intended out directory for compiler documentation.
752751
my_out = self.compiler_doc_out(target);
753752
}
754-
let rustdoc = self.rustdoc(compiler.host);
753+
let rustdoc = self.rustdoc(compiler);
755754
self.clear_if_dirty(&my_out, &rustdoc);
756755
} else if cmd != "test" {
757756
match mode {
@@ -897,7 +896,7 @@ impl<'a> Builder<'a> {
897896
.env(
898897
"RUSTDOC_REAL",
899898
if cmd == "doc" || cmd == "rustdoc" || (cmd == "test" && want_rustdoc) {
900-
self.rustdoc(compiler.host)
899+
self.rustdoc(compiler)
901900
} else {
902901
PathBuf::from("/path/to/nowhere/rustdoc/not/required")
903902
},

src/bootstrap/dist.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ impl Step for Rustc {
479479
t!(fs::create_dir_all(image.join("bin")));
480480
builder.cp_r(&src.join("bin"), &image.join("bin"));
481481

482-
builder.install(&builder.rustdoc(compiler.host), &image.join("bin"), 0o755);
482+
builder.install(&builder.rustdoc(compiler), &image.join("bin"), 0o755);
483483

484484
// Copy runtime DLLs needed by the compiler
485485
if libdir != "bin" {

src/bootstrap/doc.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ fn invoke_rustdoc(
335335
let footer = builder.src.join("src/doc/footer.inc");
336336
let version_info = out.join("version_info.html");
337337

338-
let mut cmd = builder.rustdoc_cmd(compiler.host);
338+
let mut cmd = builder.rustdoc_cmd(compiler);
339339

340340
let out = out.join("book");
341341

@@ -415,7 +415,7 @@ impl Step for Standalone {
415415
}
416416

417417
let html = out.join(filename).with_extension("html");
418-
let rustdoc = builder.rustdoc(compiler.host);
418+
let rustdoc = builder.rustdoc(compiler);
419419
if up_to_date(&path, &html) &&
420420
up_to_date(&footer, &html) &&
421421
up_to_date(&favicon, &html) &&
@@ -425,7 +425,7 @@ impl Step for Standalone {
425425
continue
426426
}
427427

428-
let mut cmd = builder.rustdoc_cmd(compiler.host);
428+
let mut cmd = builder.rustdoc_cmd(compiler);
429429
cmd.arg("--html-after-content").arg(&footer)
430430
.arg("--html-before-content").arg(&version_info)
431431
.arg("--html-in-header").arg(&favicon)
@@ -824,7 +824,7 @@ impl Step for Rustdoc {
824824
builder.ensure(Rustc { stage, target });
825825

826826
// Build rustdoc.
827-
builder.ensure(tool::Rustdoc { host: compiler.host });
827+
builder.ensure(tool::Rustdoc { compiler: compiler });
828828

829829
// Symlink compiler docs to the output directory of rustdoc documentation.
830830
let out_dir = builder.stage_out(compiler, Mode::ToolRustc)

src/bootstrap/test.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl Step for Cargotest {
177177
cmd.arg(&builder.initial_cargo)
178178
.arg(&out_dir)
179179
.env("RUSTC", builder.rustc(compiler))
180-
.env("RUSTDOC", builder.rustdoc(compiler.host)),
180+
.env("RUSTDOC", builder.rustdoc(compiler)),
181181
);
182182
}
183183
}
@@ -560,7 +560,7 @@ impl Step for RustdocTheme {
560560
builder.sysroot_libdir(self.compiler, self.compiler.host),
561561
)
562562
.env("CFG_RELEASE_CHANNEL", &builder.config.channel)
563-
.env("RUSTDOC_REAL", builder.rustdoc(self.compiler.host))
563+
.env("RUSTDOC_REAL", builder.rustdoc(self.compiler))
564564
.env("RUSTDOC_CRATE_VERSION", builder.rust_version())
565565
.env("RUSTC_BOOTSTRAP", "1");
566566
if let Some(linker) = builder.linker(self.compiler.host) {
@@ -995,7 +995,7 @@ impl Step for Compiletest {
995995
|| (mode == "ui" && is_rustdoc_ui)
996996
{
997997
cmd.arg("--rustdoc-path")
998-
.arg(builder.rustdoc(compiler.host));
998+
.arg(builder.rustdoc(compiler));
999999
}
10001000

10011001
cmd.arg("--src-base")
@@ -1451,7 +1451,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) ->
14511451
}
14521452

14531453
builder.info(&format!("doc tests for: {}", markdown.display()));
1454-
let mut cmd = builder.rustdoc_cmd(compiler.host);
1454+
let mut cmd = builder.rustdoc_cmd(compiler);
14551455
builder.add_rust_test_threads(&mut cmd);
14561456
cmd.arg("--test");
14571457
cmd.arg(markdown);

src/bootstrap/tool.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,9 @@ impl Step for RemoteTestServer {
430430

431431
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
432432
pub struct Rustdoc {
433-
pub host: Interned<String>,
433+
/// This should only ever be 0 or 2.
434+
/// We sometimes want to reference the "bootstrap" rustdoc, which is why this option is here.
435+
pub compiler: Compiler,
434436
}
435437

436438
impl Step for Rustdoc {
@@ -444,12 +446,12 @@ impl Step for Rustdoc {
444446

445447
fn make_run(run: RunConfig<'_>) {
446448
run.builder.ensure(Rustdoc {
447-
host: run.host,
449+
compiler: run.builder.compiler(run.builder.top_stage, run.host),
448450
});
449451
}
450452

451453
fn run(self, builder: &Builder<'_>) -> PathBuf {
452-
let target_compiler = builder.compiler(builder.top_stage, self.host);
454+
let target_compiler = self.compiler;
453455
if target_compiler.stage == 0 {
454456
if !target_compiler.is_snapshot(builder) {
455457
panic!("rustdoc in stage 0 must be snapshot rustdoc");

0 commit comments

Comments
 (0)