Skip to content

Commit

Permalink
Use a relative bindir for rustdoc to find rustc
Browse files Browse the repository at this point in the history
In bootstrap, we set `RUSTC_INSTALL_BINDIR` to `config.bindir`, so
rustdoc can find rustc relative to the toolchain sysroot. However, if a
distro script like Fedora's `%configure` sets an absolute path, then
rustdoc's `sysroot.join(bin_path)` ignores that sysroot altogether.

That would be OK once the toolchain is actually installed, but it breaks
the in-tree doc tests during the build, since `/usr/bin/rustc` is still
the old version. So now we try to make `RUSTC_INSTALL_BINDIR` relative
to the sysroot prefix in the first place.
  • Loading branch information
cuviper committed Nov 11, 2019
1 parent 56237d7 commit 1aee3e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/bootstrap/builder.rs
Expand Up @@ -1231,7 +1231,9 @@ impl<'a> Builder<'a> {
cargo.arg("--frozen");
}

cargo.env("RUSTC_INSTALL_BINDIR", &self.config.bindir);
// Try to use a sysroot-relative bindir, in case it was configured absolutely.
let bindir = self.config.bindir_relative().unwrap_or(&self.config.bindir);
cargo.env("RUSTC_INSTALL_BINDIR", bindir);

self.ci_env.force_coloring_in_ci(&mut cargo);

Expand Down
11 changes: 11 additions & 0 deletions src/bootstrap/config.rs
Expand Up @@ -647,6 +647,17 @@ impl Config {
config
}

/// Try to find the relative path of `bindir`.
pub fn bindir_relative(&self) -> Option<&Path> {
let bindir = &self.bindir;
if bindir.is_relative() {
Some(bindir)
} else {
// Try to make it relative to the prefix.
bindir.strip_prefix(self.prefix.as_ref()?).ok()
}
}

/// Try to find the relative path of `libdir`.
pub fn libdir_relative(&self) -> Option<&Path> {
let libdir = self.libdir.as_ref()?;
Expand Down

0 comments on commit 1aee3e4

Please sign in to comment.