1
Fork 0

Auto merge of #58238 - Mark-Simulacrum:doctest-fix, r=alexcrichton

Fixes rustdoc in stage 0, stage 1

When a request for rustdoc is passed for stage 0, x.py build --stage 0
src/tools/rustdoc or ensure(tool::Rustdoc { .. }) with top_stage = 0, we
return the rustdoc for that compiler (i.e., the beta rustdoc).

This fixes stage 0 of https://github.com/rust-lang/rust/issues/52186 as well as being part of general workflow improvements (making stage 0 testing for std work) for rustbuild.

The stage 1 fix (second commit) completely resolves the problem, so this fixes https://github.com/rust-lang/rust/issues/52186.
This commit is contained in:
bors 2019-02-13 10:27:50 +00:00
commit c005afcb1e
2 changed files with 22 additions and 23 deletions

View file

@ -677,10 +677,9 @@ impl<'a> Builder<'a> {
let compiler = self.compiler(self.top_stage, host); let compiler = self.compiler(self.top_stage, host);
cmd.env("RUSTC_STAGE", compiler.stage.to_string()) cmd.env("RUSTC_STAGE", compiler.stage.to_string())
.env("RUSTC_SYSROOT", self.sysroot(compiler)) .env("RUSTC_SYSROOT", self.sysroot(compiler))
.env( // Note that this is *not* the sysroot_libdir because rustdoc must be linked
"RUSTDOC_LIBDIR", // equivalently to rustc.
self.sysroot_libdir(compiler, self.config.build), .env("RUSTDOC_LIBDIR", self.rustc_libdir(compiler))
)
.env("CFG_RELEASE_CHANNEL", &self.config.channel) .env("CFG_RELEASE_CHANNEL", &self.config.channel)
.env("RUSTDOC_REAL", self.rustdoc(host)) .env("RUSTDOC_REAL", self.rustdoc(host))
.env("RUSTDOC_CRATE_VERSION", self.rust_version()) .env("RUSTDOC_CRATE_VERSION", self.rust_version())
@ -874,7 +873,7 @@ impl<'a> Builder<'a> {
} else { } else {
&maybe_sysroot &maybe_sysroot
}; };
let libdir = sysroot.join(libdir(&compiler.host)); let libdir = self.rustc_libdir(compiler);
// Customize the compiler we're running. Specify the compiler to cargo // Customize the compiler we're running. Specify the compiler to cargo
// as our shim and then pass it some various options used to configure // as our shim and then pass it some various options used to configure
@ -916,7 +915,7 @@ impl<'a> Builder<'a> {
cargo.env("RUSTC_ERROR_FORMAT", error_format); cargo.env("RUSTC_ERROR_FORMAT", error_format);
} }
if cmd != "build" && cmd != "check" && cmd != "rustc" && want_rustdoc { if cmd != "build" && cmd != "check" && cmd != "rustc" && want_rustdoc {
cargo.env("RUSTDOC_LIBDIR", self.sysroot_libdir(compiler, self.config.build)); cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(compiler));
} }
if mode.is_tool() { if mode.is_tool() {

View file

@ -418,25 +418,25 @@ impl Step for Rustdoc {
fn run(self, builder: &Builder) -> PathBuf { fn run(self, builder: &Builder) -> PathBuf {
let target_compiler = builder.compiler(builder.top_stage, self.host); let target_compiler = builder.compiler(builder.top_stage, self.host);
if target_compiler.stage == 0 {
if !target_compiler.is_snapshot(builder) {
panic!("rustdoc in stage 0 must be snapshot rustdoc");
}
return builder.initial_rustc.with_file_name(exe("rustdoc", &target_compiler.host));
}
let target = target_compiler.host; let target = target_compiler.host;
let build_compiler = if target_compiler.stage == 0 { // Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
builder.compiler(0, builder.config.build) // we'd have stageN/bin/rustc and stageN/bin/rustdoc be effectively different stage
} else if target_compiler.stage >= 2 { // compilers, which isn't what we want. Rustdoc should be linked in the same way as the
// Past stage 2, we consider the compiler to be ABI-compatible and hence capable of // rustc compiler it's paired with, so it must be built with the previous stage compiler.
// building rustdoc itself. let build_compiler = builder.compiler(target_compiler.stage - 1, builder.config.build);
builder.compiler(target_compiler.stage, builder.config.build)
} else {
// Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
// we'd have stageN/bin/rustc and stageN/bin/rustdoc be effectively different stage
// compilers, which isn't what we want.
builder.compiler(target_compiler.stage - 1, builder.config.build)
};
builder.ensure(compile::Rustc { compiler: build_compiler, target }); // The presence of `target_compiler` ensures that the necessary libraries (codegen backends,
builder.ensure(compile::Rustc { // compiler libraries, ...) are built. Rustdoc does not require the presence of any
compiler: build_compiler, // libraries within sysroot_libdir (i.e., rustlib), though doctests may want it (since
target: builder.config.build, // they'll be linked to those libraries). As such, don't explicitly `ensure` any additional
}); // libraries here. The intuition here is that If we've built a compiler, we should be able
// to build rustdoc.
let mut cargo = prepare_tool_cargo( let mut cargo = prepare_tool_cargo(
builder, builder,