Skip to content

Commit

Permalink
Rollup merge of rust-lang#62497 - o01eg:fix-62496, r=alexcrichton
Browse files Browse the repository at this point in the history
Fix double resolving custom libdir

Fixes rust-lang#62496

Related issue is https://bugs.gentoo.org/672816
  • Loading branch information
Centril authored Aug 20, 2019
2 parents 51879c3 + 8553cc0 commit 4593f40
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
20 changes: 13 additions & 7 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,13 +618,7 @@ impl<'a> Builder<'a> {
}

fn run(self, builder: &Builder<'_>) -> Interned<PathBuf> {
let compiler = self.compiler;
let config = &builder.build.config;
let lib = if compiler.stage >= 1 && config.libdir_relative().is_some() {
builder.build.config.libdir_relative().unwrap()
} else {
Path::new("lib")
};
let lib = builder.sysroot_libdir_relative(self.compiler);
let sysroot = builder
.sysroot(self.compiler)
.join(lib)
Expand Down Expand Up @@ -678,6 +672,18 @@ impl<'a> Builder<'a> {
}
}

/// Returns the compiler's relative libdir where the standard library and other artifacts are
/// found for a compiler's sysroot.
///
/// For example this returns `lib` on Unix and Windows.
pub fn sysroot_libdir_relative(&self, compiler: Compiler) -> &Path {
match self.config.libdir_relative() {
Some(relative_libdir) if compiler.stage >= 1
=> relative_libdir,
_ => Path::new("lib")
}
}

/// Adds the compiler's directory of dynamic libraries to `cmd`'s dynamic
/// library lookup path.
pub fn add_rustc_lib_path(&self, compiler: Compiler, cmd: &mut Command) {
Expand Down
13 changes: 9 additions & 4 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,6 @@ impl Step for Rustc {
fn prepare_image(builder: &Builder<'_>, compiler: Compiler, image: &Path) {
let host = compiler.host;
let src = builder.sysroot(compiler);
let libdir = builder.rustc_libdir(compiler);

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

// Copy runtime DLLs needed by the compiler
if libdir_relative.to_str() != Some("bin") {
let libdir = builder.rustc_libdir(compiler);
for entry in builder.read_dir(&libdir) {
let name = entry.file_name();
if let Some(s) = name.to_str() {
if is_dylib(s) {
builder.install(&entry.path(), &image.join(&libdir_relative), 0o644);
// Don't use custom libdir here because ^lib/ will be resolved again
// with installer
builder.install(&entry.path(), &image.join("lib"), 0o644);
}
}
}
}

// Copy over the codegen backends
let backends_src = builder.sysroot_codegen_backends(compiler);
let backends_rel = backends_src.strip_prefix(&src).unwrap();
let backends_dst = image.join(&backends_rel);
let backends_rel = backends_src.strip_prefix(&src).unwrap()
.strip_prefix(builder.sysroot_libdir_relative(compiler)).unwrap();
// Don't use custom libdir here because ^lib/ will be resolved again with installer
let backends_dst = image.join("lib").join(&backends_rel);

t!(fs::create_dir_all(&backends_dst));
builder.cp_r(&backends_src, &backends_dst);

Expand Down

0 comments on commit 4593f40

Please sign in to comment.