diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2019-11-13 22:09:23 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-13 22:09:23 +0900 |
| commit | 1cbd34faf226f55265822773a6a24892dfe3d044 (patch) | |
| tree | 08ee0ac6cf95f4b97451723fc899e12fa4fcb41a | |
| parent | c75a48a924e195b5417c76f0d84ad4f002ed5fab (diff) | |
| parent | bfa5e5f788593f3395cac9ba14cdefa5afd5e465 (diff) | |
| download | rust-1cbd34faf226f55265822773a6a24892dfe3d044.tar.gz rust-1cbd34faf226f55265822773a6a24892dfe3d044.zip | |
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
| -rw-r--r-- | src/bootstrap/builder.rs | 3 | ||||
| -rw-r--r-- | src/bootstrap/config.rs | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 2edcef203ad..99b8ddf7db1 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -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); diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index d1bdfa0a767..0c03b95c7b2 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -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()?; |
