about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2019-11-12 09:42:46 -0800
committerJosh Stone <jistone@redhat.com>2019-11-12 09:42:46 -0800
commitbfa5e5f788593f3395cac9ba14cdefa5afd5e465 (patch)
tree55a9995d5521cc8da6e3bf908e24643577c6c8df
parent1aee3e4d087755b40df50533dbfbc5fb80c90ff7 (diff)
downloadrust-bfa5e5f788593f3395cac9ba14cdefa5afd5e465.tar.gz
rust-bfa5e5f788593f3395cac9ba14cdefa5afd5e465.zip
Fallback to the unmodified path in bindir_relative
-rw-r--r--src/bootstrap/builder.rs3
-rw-r--r--src/bootstrap/config.rs15
2 files changed, 10 insertions, 8 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 70b53cfc4e7..10d02d6db82 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 2493167f2f5..0c03b95c7b2 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`.