diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 7bc11d88eba..7c35151a6d2 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -194,8 +194,14 @@ pub fn rustc(build: &Build, target: &str, compiler: &Compiler) { cargo.env("CFG_RELEASE", &build.release) .env("CFG_RELEASE_CHANNEL", &build.config.channel) .env("CFG_VERSION", &build.version) - .env("CFG_PREFIX", build.config.prefix.clone().unwrap_or(PathBuf::new())) - .env("CFG_LIBDIR_RELATIVE", "lib"); + .env("CFG_PREFIX", build.config.prefix.clone().unwrap_or(PathBuf::new())); + + if compiler.stage == 0 { + cargo.env("CFG_LIBDIR_RELATIVE", "lib"); + } else { + let libdir_relative = 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 // these two env vars which would be set otherwise. diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 8e2129758f6..152164342cd 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -90,6 +90,7 @@ pub struct Config { pub prefix: Option, pub docdir: Option, pub libdir: Option, + pub libdir_relative: Option, pub mandir: Option, pub codegen_tests: bool, pub nodejs: Option, @@ -477,6 +478,9 @@ impl Config { "CFG_LIBDIR" => { self.libdir = Some(PathBuf::from(value)); } + "CFG_LIBDIR_RELATIVE" => { + self.libdir_relative = Some(PathBuf::from(value)); + } "CFG_MANDIR" => { self.mandir = Some(PathBuf::from(value)); }