Skip to content

Commit 1aee3e4

Browse files
committed
Use a relative bindir for rustdoc to find rustc
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.
1 parent 56237d7 commit 1aee3e4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/bootstrap/builder.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,9 @@ impl<'a> Builder<'a> {
12311231
cargo.arg("--frozen");
12321232
}
12331233

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

12361238
self.ci_env.force_coloring_in_ci(&mut cargo);
12371239

src/bootstrap/config.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,17 @@ impl Config {
647647
config
648648
}
649649

650+
/// Try to find the relative path of `bindir`.
651+
pub fn bindir_relative(&self) -> Option<&Path> {
652+
let bindir = &self.bindir;
653+
if bindir.is_relative() {
654+
Some(bindir)
655+
} else {
656+
// Try to make it relative to the prefix.
657+
bindir.strip_prefix(self.prefix.as_ref()?).ok()
658+
}
659+
}
660+
650661
/// Try to find the relative path of `libdir`.
651662
pub fn libdir_relative(&self) -> Option<&Path> {
652663
let libdir = self.libdir.as_ref()?;

0 commit comments

Comments
 (0)