diff options
| author | Josh Stone <jistone@redhat.com> | 2018-02-19 14:05:21 -0800 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2018-02-19 14:17:31 -0800 |
| commit | 80970e6953faaba886215d8abd34e70f1d510103 (patch) | |
| tree | de0deb152aa4d56c21ad3a95e4c53aa9424bb533 /src/bootstrap | |
| parent | 27a046e9338fb0455c33b13e8fe28da78212dedc (diff) | |
| download | rust-80970e6953faaba886215d8abd34e70f1d510103.tar.gz rust-80970e6953faaba886215d8abd34e70f1d510103.zip | |
rustbuild: Restore Config.libdir_relative
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.
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/builder.rs | 4 | ||||
| -rw-r--r-- | src/bootstrap/compile.rs | 2 | ||||
| -rw-r--r-- | src/bootstrap/config.rs | 17 |
3 files changed, 20 insertions, 3 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 66a1c972462..05aa6283ee5 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -444,8 +444,8 @@ impl<'a> Builder<'a> { 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") }; diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 2dcc0e0e7cd..e6389f27785 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -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 diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 812ca6d64fb..6d98153e233 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -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 @@ impl 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; |
