Skip to content

Commit d880128

Browse files
committed
Auto merge of #39206 - MJDSys:fix_rustbuild_libdir, r=alexcrichton
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. I'm not sure how you want this handled in the toml system (my distribution, Gentoo, uses configure still). I have a feeling the system needs a rework anyways for rustbuild. If there is some discussion that needs to happen, could you merge this in the mean time? I'd be happy to help transition this to a better method.
2 parents b4cb187 + 4c02d9f commit d880128

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
@@ -194,8 +194,14 @@ pub fn rustc(build: &Build, target: &str, compiler: &Compiler) {
194194
cargo.env("CFG_RELEASE", &build.release)
195195
.env("CFG_RELEASE_CHANNEL", &build.config.channel)
196196
.env("CFG_VERSION", &build.version)
197-
.env("CFG_PREFIX", build.config.prefix.clone().unwrap_or(PathBuf::new()))
198-
.env("CFG_LIBDIR_RELATIVE", "lib");
197+
.env("CFG_PREFIX", build.config.prefix.clone().unwrap_or(PathBuf::new()));
198+
199+
if compiler.stage == 0 {
200+
cargo.env("CFG_LIBDIR_RELATIVE", "lib");
201+
} else {
202+
let libdir_relative = build.config.libdir_relative.clone().unwrap_or(PathBuf::from("lib"));
203+
cargo.env("CFG_LIBDIR_RELATIVE", libdir_relative);
204+
}
199205

200206
// If we're not building a compiler with debugging information then remove
201207
// 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)