Skip to content
Permalink
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.
  • Loading branch information...
Mark-Simulacrum committed Mar 3, 2019
1 parent 9efc93c commit 03718ed67a7b8fd57fc27316ec57ac3bc0f13d06
Showing with 21 additions and 20 deletions.
  1. +7 −8 src/bootstrap/builder.rs
  2. +1 −1 src/bootstrap/dist.rs
  3. +4 −4 src/bootstrap/doc.rs
  4. +4 −4 src/bootstrap/test.rs
  5. +5 −3 src/bootstrap/tool.rs
@@ -668,28 +668,27 @@ impl<'a> Builder<'a> {
.map(|entry| entry.path())
}

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

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

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

if let Some(linker) = self.linker(host) {
if let Some(linker) = self.linker(compiler.host) {
cmd.env("RUSTC_TARGET_LINKER", linker);
}
cmd
@@ -751,7 +750,7 @@ impl<'a> Builder<'a> {
// This is the intended out directory for compiler documentation.
my_out = self.compiler_doc_out(target);
}
let rustdoc = self.rustdoc(compiler.host);
let rustdoc = self.rustdoc(compiler);
self.clear_if_dirty(&my_out, &rustdoc);
} else if cmd != "test" {
match mode {
@@ -897,7 +896,7 @@ impl<'a> Builder<'a> {
.env(
"RUSTDOC_REAL",
if cmd == "doc" || cmd == "rustdoc" || (cmd == "test" && want_rustdoc) {
self.rustdoc(compiler.host)
self.rustdoc(compiler)
} else {
PathBuf::from("/path/to/nowhere/rustdoc/not/required")
},
@@ -479,7 +479,7 @@ impl Step for Rustc {
t!(fs::create_dir_all(image.join("bin")));
builder.cp_r(&src.join("bin"), &image.join("bin"));

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

// Copy runtime DLLs needed by the compiler
if libdir != "bin" {
@@ -335,7 +335,7 @@ fn invoke_rustdoc(
let footer = builder.src.join("src/doc/footer.inc");
let version_info = out.join("version_info.html");

let mut cmd = builder.rustdoc_cmd(compiler.host);
let mut cmd = builder.rustdoc_cmd(compiler);

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

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

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

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

// Build rustdoc.
builder.ensure(tool::Rustdoc { host: compiler.host });
builder.ensure(tool::Rustdoc { compiler: compiler });

// Symlink compiler docs to the output directory of rustdoc documentation.
let out_dir = builder.stage_out(compiler, Mode::ToolRustc)
@@ -177,7 +177,7 @@ impl Step for Cargotest {
cmd.arg(&builder.initial_cargo)
.arg(&out_dir)
.env("RUSTC", builder.rustc(compiler))
.env("RUSTDOC", builder.rustdoc(compiler.host)),
.env("RUSTDOC", builder.rustdoc(compiler)),
);
}
}
@@ -560,7 +560,7 @@ impl Step for RustdocTheme {
builder.sysroot_libdir(self.compiler, self.compiler.host),
)
.env("CFG_RELEASE_CHANNEL", &builder.config.channel)
.env("RUSTDOC_REAL", builder.rustdoc(self.compiler.host))
.env("RUSTDOC_REAL", builder.rustdoc(self.compiler))
.env("RUSTDOC_CRATE_VERSION", builder.rust_version())
.env("RUSTC_BOOTSTRAP", "1");
if let Some(linker) = builder.linker(self.compiler.host) {
@@ -995,7 +995,7 @@ impl Step for Compiletest {
|| (mode == "ui" && is_rustdoc_ui)
{
cmd.arg("--rustdoc-path")
.arg(builder.rustdoc(compiler.host));
.arg(builder.rustdoc(compiler));
}

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

builder.info(&format!("doc tests for: {}", markdown.display()));
let mut cmd = builder.rustdoc_cmd(compiler.host);
let mut cmd = builder.rustdoc_cmd(compiler);
builder.add_rust_test_threads(&mut cmd);
cmd.arg("--test");
cmd.arg(markdown);
@@ -430,7 +430,9 @@ impl Step for RemoteTestServer {

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

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

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(Rustdoc {
host: run.host,
compiler: run.builder.compiler(run.builder.top_stage, run.host),
});
}

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

0 comments on commit 03718ed

Please sign in to comment.
You can’t perform that action at this time.