Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix custom relative libdir." #59668

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,28 +634,7 @@ impl<'a> Builder<'a> {
if compiler.is_snapshot(self) {
self.rustc_snapshot_libdir()
} else {
match self.config.libdir_relative() {
Some(relative_libdir) if compiler.stage >= 1
=> self.sysroot(compiler).join(relative_libdir),
_ => self.sysroot(compiler).join(libdir(&compiler.host))
}
}
}

/// Returns the compiler's relative libdir where it stores the dynamic libraries that
/// it itself links against.
///
/// For example this returns `lib` on Unix and `bin` on
/// Windows.
pub fn libdir_relative(&self, compiler: Compiler) -> &Path {
if compiler.is_snapshot(self) {
libdir(&self.config.build).as_ref()
} else {
match self.config.libdir_relative() {
Some(relative_libdir) if compiler.stage >= 1
=> relative_libdir,
_ => libdir(&compiler.host).as_ref()
}
self.sysroot(compiler).join(libdir(&compiler.host))
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use filetime::FileTime;
use serde_json;

use crate::dist;
use crate::util::{exe, is_dylib};
use crate::util::{exe, libdir, is_dylib};
use crate::{Compiler, Mode, GitRepo};
use crate::native;

Expand Down Expand Up @@ -1005,13 +1005,13 @@ impl Step for Assemble {

// Link in all dylibs to the libdir
let sysroot = builder.sysroot(target_compiler);
let rustc_libdir = builder.rustc_libdir(target_compiler);
t!(fs::create_dir_all(&rustc_libdir));
let sysroot_libdir = sysroot.join(libdir(&*host));
t!(fs::create_dir_all(&sysroot_libdir));
let src_libdir = builder.sysroot_libdir(build_compiler, host);
for f in builder.read_dir(&src_libdir) {
let filename = f.file_name().into_string().unwrap();
if is_dylib(&filename) {
builder.copy(&f.path(), &rustc_libdir.join(&filename));
builder.copy(&f.path(), &sysroot_libdir.join(&filename));
}
}

Expand Down
15 changes: 6 additions & 9 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use build_helper::output;

use crate::{Compiler, Mode, LLVM_TOOLS};
use crate::channel;
use crate::util::{is_dylib, exe};
use crate::util::{libdir, is_dylib, exe};
use crate::builder::{Builder, RunConfig, ShouldRun, Step};
use crate::compile;
use crate::tool::{self, Tool};
Expand Down Expand Up @@ -473,23 +473,21 @@ 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);
let libdir = libdir(&host);

// Copy rustc/rustdoc binaries
t!(fs::create_dir_all(image.join("bin")));
builder.cp_r(&src.join("bin"), &image.join("bin"));

builder.install(&builder.rustdoc(compiler), &image.join("bin"), 0o755);

let libdir_relative = builder.libdir_relative(compiler);

// Copy runtime DLLs needed by the compiler
if libdir_relative.to_str() != Some("bin") {
for entry in builder.read_dir(&libdir) {
if libdir != "bin" {
for entry in builder.read_dir(&src.join(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);
builder.install(&entry.path(), &image.join(libdir), 0o644);
}
}
}
Expand Down Expand Up @@ -518,8 +516,7 @@ impl Step for Rustc {
.join("bin")
.join(&exe);
// for the rationale about this rename check `compile::copy_lld_to_sysroot`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this part only should be reverted, could you check it on windows?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I don't have a Windows machine to test on, so I'm just trying to fix the regession quickly.

let dst = image.join(libdir_relative)
.join("rustlib")
let dst = image.join("lib/rustlib")
.join(&*host)
.join("bin")
.join(&exe);
Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,6 @@ impl Build {
fn install(&self, src: &Path, dstdir: &Path, perms: u32) {
if self.config.dry_run { return; }
let dst = dstdir.join(src.file_name().unwrap());
self.verbose_than(1, &format!("Install {:?} to {:?}", src, dst));
t!(fs::create_dir_all(dstdir));
drop(fs::remove_file(&dst));
{
Expand Down