From 6def641ded390e7743c4ac48c26eb580acf2c662 Mon Sep 17 00:00:00 2001 From: O01eg Date: Wed, 6 Mar 2019 10:47:34 +0300 Subject: [PATCH 1/2] Fix rustdoc execution on multiple targets and custom libdir. Fixes #58587 Reverts #58238 Show `dylib_path` for rustdoc commands like rustc. --- src/bootstrap/builder.rs | 3 ++- src/bootstrap/tool.rs | 28 ++++++++++++++++------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 414033a5e2fed..6e3438ec68141 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -927,7 +927,8 @@ impl<'a> Builder<'a> { cargo.env("RUSTC_ERROR_FORMAT", error_format); } if cmd != "build" && cmd != "check" && cmd != "rustc" && want_rustdoc { - cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(compiler)); + // sysroot libdir required for case with custom libdir + cargo.env("RUSTDOC_LIBDIR", self.sysroot_libdir(compiler, self.config.build)); } if mode.is_tool() { diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 865b1f8268c32..b278b92c29c3c 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -426,18 +426,22 @@ impl Step for Rustdoc { return builder.initial_rustc.with_file_name(exe("rustdoc", &target_compiler.host)); } let target = target_compiler.host; - // 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. Rustdoc should be linked in the same way as the - // rustc compiler it's paired with, so it must be built with the previous stage compiler. - let build_compiler = builder.compiler(target_compiler.stage - 1, builder.config.build); - - // The presence of `target_compiler` ensures that the necessary libraries (codegen backends, - // compiler libraries, ...) are built. Rustdoc does not require the presence of any - // libraries within sysroot_libdir (i.e., rustlib), though doctests may want it (since - // 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 build_compiler = if target_compiler.stage >= 2 { + // Past stage 2, we consider the compiler to be ABI-compatible and hence capable of + // building rustdoc itself. + 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) + }; + + // require host compiler so documentation of other targets won't fail on missing libraries + builder.ensure(compile::Rustc { + compiler: build_compiler, + target: builder.config.build, + }); let mut cargo = prepare_tool_cargo( builder, From d8bd9d392d4437be5859fc03fda14cf5f9e8afd7 Mon Sep 17 00:00:00 2001 From: O01eg Date: Wed, 20 Mar 2019 16:54:14 +0300 Subject: [PATCH 2/2] Fix custom relative libdir. --- src/bootstrap/builder.rs | 6 +++++- src/bootstrap/compile.rs | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 6e3438ec68141..34cb8906eab70 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -632,7 +632,11 @@ impl<'a> Builder<'a> { if compiler.is_snapshot(self) { self.rustc_snapshot_libdir() } else { - self.sysroot(compiler).join(libdir(&compiler.host)) + match self.config.libdir_relative() { + Some(relative_libdir) if compiler.stage >= 1 + => self.sysroot(compiler).join(relative_libdir), + _ => self.sysroot(compiler).join(libdir(&compiler.host)) + } } } diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 9498dbb595232..4c9cd210f2ae5 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -20,7 +20,7 @@ use filetime::FileTime; use serde_json; use crate::dist; -use crate::util::{exe, libdir, is_dylib}; +use crate::util::{exe, is_dylib}; use crate::{Compiler, Mode, GitRepo}; use crate::native; @@ -988,13 +988,13 @@ impl Step for Assemble { // Link in all dylibs to the libdir let sysroot = builder.sysroot(target_compiler); - let sysroot_libdir = sysroot.join(libdir(&*host)); - t!(fs::create_dir_all(&sysroot_libdir)); + let rustc_libdir = builder.rustc_libdir(target_compiler); + t!(fs::create_dir_all(&rustc_libdir)); let src_libdir = builder.sysroot_libdir(build_compiler, host); for f in builder.read_dir(&src_libdir) { let filename = f.file_name().into_string().unwrap(); if is_dylib(&filename) { - builder.copy(&f.path(), &sysroot_libdir.join(&filename)); + builder.copy(&f.path(), &rustc_libdir.join(&filename)); } }