Skip to content

Commit

Permalink
Get libdir from stage0 compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
o01eg committed May 29, 2020
1 parent ce72299 commit c0ac2e8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ impl<'a> Builder<'a> {
pub fn sysroot_libdir_relative(&self, compiler: Compiler) -> &Path {
match self.config.libdir_relative() {
Some(relative_libdir) if compiler.stage >= 1 => relative_libdir,
_ if compiler.stage == 0 => &self.build.initial_libdir,
_ => Path::new("lib"),
}
}
Expand Down
24 changes: 20 additions & 4 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ pub struct Build {
initial_rustc: PathBuf,
initial_cargo: PathBuf,
initial_lld: PathBuf,
initial_libdir: PathBuf,

// Runtime state filled in later on
// C/C++ compilers and archiver for all targets
Expand Down Expand Up @@ -344,8 +345,8 @@ impl Build {
// we always try to use git for LLVM builds
let in_tree_llvm_info = channel::GitInfo::new(false, &src.join("src/llvm-project"));

let initial_target_libdir = if config.dry_run {
"/dummy/path/to/lib/".to_string()
let initial_target_libdir_str = if config.dry_run {
"/dummy/lib/path/to/lib/".to_string()
} else {
output(
Command::new(&config.initial_rustc)
Expand All @@ -355,13 +356,28 @@ impl Build {
.arg("target-libdir"),
)
};
let initial_lld =
Path::new(&initial_target_libdir).parent().unwrap().join("bin").join("rust-lld");
let initial_target_dir = Path::new(&initial_target_libdir_str).parent().unwrap();
let initial_lld = initial_target_dir.join("bin").join("rust-lld");

let initial_sysroot = if config.dry_run {
"/dummy".to_string()
} else {
output(Command::new(&config.initial_rustc).arg("--print").arg("sysroot"))
};
let initial_libdir = initial_target_dir
.parent()
.unwrap()
.parent()
.unwrap()
.strip_prefix(initial_sysroot.trim())
.unwrap()
.to_path_buf();

let mut build = Build {
initial_rustc: config.initial_rustc.clone(),
initial_cargo: config.initial_cargo.clone(),
initial_lld,
initial_libdir,
local_rebuild: config.local_rebuild,
fail_fast: config.cmd.fail_fast(),
doc_tests: config.cmd.doc_tests(),
Expand Down

0 comments on commit c0ac2e8

Please sign in to comment.