Skip to content

Commit 4c02d9f

Browse files
committed
Fix rustbuild to work with --libdir.
Similar to the makefiles, pass CFG_LIBDIR_RELATIVE to cargo when building rustc in stages > 0. This tells rustc to check the different directory.
1 parent b7ca2b9 commit 4c02d9f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/bootstrap/compile.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,14 @@ pub fn rustc(build: &Build, target: &str, compiler: &Compiler) {
185185
cargo.env("CFG_RELEASE", &build.release)
186186
.env("CFG_RELEASE_CHANNEL", &build.config.channel)
187187
.env("CFG_VERSION", &build.version)
188-
.env("CFG_PREFIX", build.config.prefix.clone().unwrap_or(PathBuf::new()))
189-
.env("CFG_LIBDIR_RELATIVE", "lib");
188+
.env("CFG_PREFIX", build.config.prefix.clone().unwrap_or(PathBuf::new()));
189+
190+
if compiler.stage == 0 {
191+
cargo.env("CFG_LIBDIR_RELATIVE", "lib");
192+
} else {
193+
let libdir_relative = build.config.libdir_relative.clone().unwrap_or(PathBuf::from("lib"));
194+
cargo.env("CFG_LIBDIR_RELATIVE", libdir_relative);
195+
}
190196

191197
// If we're not building a compiler with debugging information then remove
192198
// these two env vars which would be set otherwise.

src/bootstrap/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ pub struct Config {
9090
pub prefix: Option<PathBuf>,
9191
pub docdir: Option<PathBuf>,
9292
pub libdir: Option<PathBuf>,
93+
pub libdir_relative: Option<PathBuf>,
9394
pub mandir: Option<PathBuf>,
9495
pub codegen_tests: bool,
9596
pub nodejs: Option<PathBuf>,
@@ -477,6 +478,9 @@ impl Config {
477478
"CFG_LIBDIR" => {
478479
self.libdir = Some(PathBuf::from(value));
479480
}
481+
"CFG_LIBDIR_RELATIVE" => {
482+
self.libdir_relative = Some(PathBuf::from(value));
483+
}
480484
"CFG_MANDIR" => {
481485
self.mandir = Some(PathBuf::from(value));
482486
}

0 commit comments

Comments
 (0)