From 89f4b3c8bc90280f42cc640177c0287a1195c682 Mon Sep 17 00:00:00 2001 From: Rust Maintainers Date: Wed, 7 Mar 2018 19:07:27 +0000 Subject: [PATCH] u-rust-pr48362-libdir-relative Gbp-Pq: Name u-rust-pr48362-libdir-relative.patch --- src/bootstrap/builder.rs | 7 ++++--- src/bootstrap/compile.rs | 3 +-- src/bootstrap/config.rs | 13 ++++++++++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index a660b5cf85..082651de3c 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -357,10 +357,11 @@ impl<'a> Builder<'a> { fn run(self, builder: &Builder) -> Interned { let compiler = self.compiler; - let lib = if compiler.stage >= 1 && builder.build.config.libdir.is_some() { - builder.build.config.libdir.clone().unwrap() + let config = &builder.build.config; + let lib = if compiler.stage >= 1 && config.libdir_relative().is_some() { + builder.build.config.libdir_relative().unwrap() } else { - PathBuf::from("lib") + Path::new("lib") }; let sysroot = builder.sysroot(self.compiler).join(lib) .join("rustlib").join(self.target).join("lib"); diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index c6adfc7ffa..6ccfce54b9 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -513,8 +513,7 @@ pub fn rustc_cargo(build: &Build, .env("CFG_VERSION", build.rust_version()) .env("CFG_PREFIX", build.config.prefix.clone().unwrap_or_default()); - let libdir_relative = - build.config.libdir.clone().unwrap_or(PathBuf::from("lib")); + let libdir_relative = build.config.libdir_relative().unwrap_or(Path::new("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 72e75fddc1..b138e1a58e 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -17,7 +17,7 @@ use std::collections::HashMap; use std::env; use std::fs::File; use std::io::prelude::*; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::process; use std::cmp; @@ -542,6 +542,17 @@ impl Config { config } + /// Try to find the relative path of `libdir`. + pub fn libdir_relative(&self) -> Option<&Path> { + let libdir = self.libdir.as_ref()?; + if libdir.is_relative() { + Some(libdir) + } else { + // Try to make it relative to the prefix. + libdir.strip_prefix(self.prefix.as_ref()?).ok() + } + } + pub fn verbose(&self) -> bool { self.verbose > 0 } -- 2.30.2