Skip to content

Commit ce3abc5

Browse files
committed
Fix stage 2 builds with a custom libdir.
When copying libstd for the stage 2 compiler, the builder ignores the configured libdir/libdir_relative configuration parameters. This causes the compiler to fail to find libstd, which cause any tools built with the stage 2 compiler to fail. To fix this, make the copy steps of rustbuild aware of the libdir_relative parameter when the stage >= 2. Also update the dist target to be aware of the new location of libstd.
1 parent 9b85e1c commit ce3abc5

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/bootstrap/dist.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,9 @@ pub fn std(build: &Build, compiler: &Compiler, target: &str) {
405405

406406
let dst = image.join("lib/rustlib").join(target);
407407
t!(fs::create_dir_all(&dst));
408-
let src = build.sysroot(compiler).join("lib/rustlib");
409-
cp_r(&src.join(target), &dst);
408+
let mut src = build.sysroot_libdir(compiler, target);
409+
src.pop(); // Remove the trailing /lib folder from the sysroot_libdir
410+
cp_r(&src, &dst);
410411

411412
let mut cmd = rust_installer(build);
412413
cmd.arg("generate")

src/bootstrap/lib.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -645,8 +645,14 @@ impl Build {
645645
/// Returns the libdir where the standard library and other artifacts are
646646
/// found for a compiler's sysroot.
647647
fn sysroot_libdir(&self, compiler: &Compiler, target: &str) -> PathBuf {
648-
self.sysroot(compiler).join("lib").join("rustlib")
649-
.join(target).join("lib")
648+
if compiler.stage >= 2 {
649+
if let Some(ref libdir_relative) = self.config.libdir_relative {
650+
return self.sysroot(compiler).join(libdir_relative)
651+
.join("rustlib").join(target).join("lib")
652+
}
653+
}
654+
self.sysroot(compiler).join("lib").join("rustlib")
655+
.join(target).join("lib")
650656
}
651657

652658
/// Returns the root directory for all output generated in a particular

0 commit comments

Comments
 (0)