From bfa5e5f788593f3395cac9ba14cdefa5afd5e465 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 12 Nov 2019 09:42:46 -0800 Subject: [PATCH] Fallback to the unmodified path in bindir_relative --- src/bootstrap/builder.rs | 3 +-- src/bootstrap/config.rs | 15 +++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 70b53cfc4e752..10d02d6db8299 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1232,8 +1232,7 @@ impl<'a> Builder<'a> { } // 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); + 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 2493167f2f5e5..0c03b95c7b251 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -647,15 +647,18 @@ impl Config { config } - /// Try to find the relative path of `bindir`. - pub fn bindir_relative(&self) -> Option<&Path> { + /// 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_relative() { - Some(bindir) - } else { + if bindir.is_absolute() { // Try to make it relative to the prefix. - bindir.strip_prefix(self.prefix.as_ref()?).ok() + 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`.