Rollup merge of #66317 - cuviper:bindir_relative, r=Mark-Simulacrum
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. r? @Mark-Simulacrum
This commit is contained in:
commit
1cbd34faf2
@ -1242,7 +1242,8 @@ 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.
|
||||
cargo.env("RUSTC_INSTALL_BINDIR", self.config.bindir_relative());
|
||||
|
||||
self.ci_env.force_coloring_in_ci(&mut cargo);
|
||||
|
||||
|
@ -647,6 +647,20 @@ impl Config {
|
||||
config
|
||||
}
|
||||
|
||||
/// Try to find the relative path of `bindir`, otherwise return it in full.
|
||||
pub fn bindir_relative(&self) -> &Path {
|
||||
let bindir = &self.bindir;
|
||||
if bindir.is_absolute() {
|
||||
// Try to make it relative to the prefix.
|
||||
if let Some(prefix) = &self.prefix {
|
||||
if let Ok(stripped) = bindir.strip_prefix(prefix) {
|
||||
return stripped;
|
||||
}
|
||||
}
|
||||
}
|
||||
bindir
|
||||
}
|
||||
|
||||
/// Try to find the relative path of `libdir`.
|
||||
pub fn libdir_relative(&self) -> Option<&Path> {
|
||||
let libdir = self.libdir.as_ref()?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user