From c0ac2e86f9d7545594fdb1be27f2fe9336699ca7 Mon Sep 17 00:00:00 2001 From: O01eg Date: Fri, 29 May 2020 10:15:46 +0300 Subject: [PATCH] Get libdir from stage0 compiler --- src/bootstrap/builder.rs | 1 + src/bootstrap/lib.rs | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 5489b1bc66b64..c8a85eae252ff 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -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"), } } diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 5328ccb64df7e..c46c68e4d5682 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -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 @@ -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) @@ -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(),