]> git.lizzy.rs Git - rust.git/commitdiff
rustbuild: Restore Config.libdir_relative
authorJosh Stone <jistone@redhat.com>
Mon, 19 Feb 2018 22:05:21 +0000 (14:05 -0800)
committerJosh Stone <jistone@redhat.com>
Mon, 19 Feb 2018 22:17:31 +0000 (14:17 -0800)
This re-introduces a `Config.libdir_relative` field, now derived from
`libdir` and made relative to `prefix` if necessary.

This fixes a regression from #46592 when `--libdir` is given an absolute
path.  `Builder::sysroot_libdir` should always use a relative path so
its callers don't clobber system locations, and `librustc` also asserts
that `CFG_LIBDIR_RELATIVE` is really relative.

src/bootstrap/builder.rs
src/bootstrap/compile.rs
src/bootstrap/config.rs

index 66a1c97246200d5c68a94817625929bdac17d22a..05aa6283ee579630296e97110f8173dcb71b832d 100644 (file)
@@ -444,8 +444,8 @@ fn should_run(run: ShouldRun) -> ShouldRun {
 
             fn run(self, builder: &Builder) -> Interned<PathBuf> {
                 let compiler = self.compiler;
-                let lib = if compiler.stage >= 1 && builder.build.config.libdir.is_some() {
-                    builder.build.config.libdir.clone().unwrap()
+                let lib = if compiler.stage >= 1 && builder.build.config.libdir_relative.is_some() {
+                    builder.build.config.libdir_relative.clone().unwrap()
                 } else {
                     PathBuf::from("lib")
                 };
index 2dcc0e0e7cd9f0110a583a93ad1450cb7ca3d08a..e6389f27785b509c2cc0892bb0c1d5a492c2fe9c 100644 (file)
@@ -517,7 +517,7 @@ fn rustc_cargo_env(build: &Build, cargo: &mut Command) {
          .env("CFG_PREFIX", build.config.prefix.clone().unwrap_or_default());
 
     let libdir_relative =
-        build.config.libdir.clone().unwrap_or(PathBuf::from("lib"));
+        build.config.libdir_relative.clone().unwrap_or(PathBuf::from("lib"));
     cargo.env("CFG_LIBDIR_RELATIVE", libdir_relative);
 
     // If we're not building a compiler with debugging information then remove
index 812ca6d64fb6a792545749b84857175a6c36db92..6d98153e233ba55051693aeb846bbdbb138e84f5 100644 (file)
@@ -126,6 +126,7 @@ pub struct Config {
     pub docdir: Option<PathBuf>,
     pub bindir: Option<PathBuf>,
     pub libdir: Option<PathBuf>,
+    pub libdir_relative: Option<PathBuf>,
     pub mandir: Option<PathBuf>,
     pub codegen_tests: bool,
     pub nodejs: Option<PathBuf>,
@@ -417,6 +418,22 @@ pub fn parse(args: &[String]) -> Config {
             config.mandir = install.mandir.clone().map(PathBuf::from);
         }
 
+        // Try to infer `libdir_relative` from `libdir`.
+        if let Some(ref libdir) = config.libdir {
+            let mut libdir = libdir.as_path();
+            if !libdir.is_relative() {
+                // Try to make it relative to the prefix.
+                if let Some(ref prefix) = config.prefix {
+                    if let Ok(suffix) = libdir.strip_prefix(prefix) {
+                        libdir = suffix;
+                    }
+                }
+            }
+            if libdir.is_relative() {
+                config.libdir_relative = Some(libdir.to_path_buf());
+            }
+        }
+
         // Store off these values as options because if they're not provided
         // we'll infer default values for them later
         let mut thinlto = None;