Skip to content

Commit 8553cc0

Browse files
committed
Fix double resolving custom libdir
1 parent d4abb08 commit 8553cc0

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
@@ -627,13 +627,7 @@ impl<'a> Builder<'a> {
627627
}
628628

629629
fn run(self, builder: &Builder<'_>) -> Interned<PathBuf> {
630-
let compiler = self.compiler;
631-
let config = &builder.build.config;
632-
let lib = if compiler.stage >= 1 && config.libdir_relative().is_some() {
633-
builder.build.config.libdir_relative().unwrap()
634-
} else {
635-
Path::new("lib")
636-
};
630+
let lib = builder.sysroot_libdir_relative(self.compiler);
637631
let sysroot = builder
638632
.sysroot(self.compiler)
639633
.join(lib)
@@ -687,6 +681,18 @@ impl<'a> Builder<'a> {
687681
}
688682
}
689683

684+
/// Returns the compiler's relative libdir where the standard library and other artifacts are
685+
/// found for a compiler's sysroot.
686+
///
687+
/// For example this returns `lib` on Unix and Windows.
688+
pub fn sysroot_libdir_relative(&self, compiler: Compiler) -> &Path {
689+
match self.config.libdir_relative() {
690+
Some(relative_libdir) if compiler.stage >= 1
691+
=> relative_libdir,
692+
_ => Path::new("lib")
693+
}
694+
}
695+
690696
/// Adds the compiler's directory of dynamic libraries to `cmd`'s dynamic
691697
/// library lookup path.
692698
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)