Skip to content

Commit 4593f40

Browse files
authored
Rollup merge of #62497 - o01eg:fix-62496, r=alexcrichton
Fix double resolving custom libdir Fixes #62496 Related issue is https://bugs.gentoo.org/672816
2 parents 51879c3 + 8553cc0 commit 4593f40

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/bootstrap/builder.rs

+13-7
Original file line numberDiff line numberDiff line change
@@ -618,13 +618,7 @@ impl<'a> Builder<'a> {
618618
}
619619

620620
fn run(self, builder: &Builder<'_>) -> Interned<PathBuf> {
621-
let compiler = self.compiler;
622-
let config = &builder.build.config;
623-
let lib = if compiler.stage >= 1 && config.libdir_relative().is_some() {
624-
builder.build.config.libdir_relative().unwrap()
625-
} else {
626-
Path::new("lib")
627-
};
621+
let lib = builder.sysroot_libdir_relative(self.compiler);
628622
let sysroot = builder
629623
.sysroot(self.compiler)
630624
.join(lib)
@@ -678,6 +672,18 @@ impl<'a> Builder<'a> {
678672
}
679673
}
680674

675+
/// Returns the compiler's relative libdir where the standard library and other artifacts are
676+
/// found for a compiler's sysroot.
677+
///
678+
/// For example this returns `lib` on Unix and Windows.
679+
pub fn sysroot_libdir_relative(&self, compiler: Compiler) -> &Path {
680+
match self.config.libdir_relative() {
681+
Some(relative_libdir) if compiler.stage >= 1
682+
=> relative_libdir,
683+
_ => Path::new("lib")
684+
}
685+
}
686+
681687
/// Adds the compiler's directory of dynamic libraries to `cmd`'s dynamic
682688
/// library lookup path.
683689
pub fn add_rustc_lib_path(&self, compiler: Compiler, cmd: &mut Command) {

src/bootstrap/dist.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@ impl Step for Rustc {
469469
fn prepare_image(builder: &Builder<'_>, compiler: Compiler, image: &Path) {
470470
let host = compiler.host;
471471
let src = builder.sysroot(compiler);
472-
let libdir = builder.rustc_libdir(compiler);
473472

474473
// Copy rustc/rustdoc binaries
475474
t!(fs::create_dir_all(image.join("bin")));
@@ -481,20 +480,26 @@ impl Step for Rustc {
481480

482481
// Copy runtime DLLs needed by the compiler
483482
if libdir_relative.to_str() != Some("bin") {
483+
let libdir = builder.rustc_libdir(compiler);
484484
for entry in builder.read_dir(&libdir) {
485485
let name = entry.file_name();
486486
if let Some(s) = name.to_str() {
487487
if is_dylib(s) {
488-
builder.install(&entry.path(), &image.join(&libdir_relative), 0o644);
488+
// Don't use custom libdir here because ^lib/ will be resolved again
489+
// with installer
490+
builder.install(&entry.path(), &image.join("lib"), 0o644);
489491
}
490492
}
491493
}
492494
}
493495

494496
// Copy over the codegen backends
495497
let backends_src = builder.sysroot_codegen_backends(compiler);
496-
let backends_rel = backends_src.strip_prefix(&src).unwrap();
497-
let backends_dst = image.join(&backends_rel);
498+
let backends_rel = backends_src.strip_prefix(&src).unwrap()
499+
.strip_prefix(builder.sysroot_libdir_relative(compiler)).unwrap();
500+
// Don't use custom libdir here because ^lib/ will be resolved again with installer
501+
let backends_dst = image.join("lib").join(&backends_rel);
502+
498503
t!(fs::create_dir_all(&backends_dst));
499504
builder.cp_r(&backends_src, &backends_dst);
500505

0 commit comments

Comments
 (0)