about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-05-30 23:08:57 +0200
committerGitHub <noreply@github.com>2020-05-30 23:08:57 +0200
commit8f1c0d0a10761b70d74bec7a537a25cb54f42b61 (patch)
tree697e829cf22a03ca93be00a5232b6bc335193aa6
parent278e26eaf6a2b8312aadb7b05d432182dae55ce4 (diff)
parentc0ac2e86f9d7545594fdb1be27f2fe9336699ca7 (diff)
downloadrust-8f1c0d0a10761b70d74bec7a537a25cb54f42b61.tar.gz
rust-8f1c0d0a10761b70d74bec7a537a25cb54f42b61.zip
Rollup merge of #72728 - o01eg:fix-72661, r=Mark-Simulacrum
Make bootstrap aware of relative libdir in stage0 compiler

Follows up #72692

Fixes #72661
-rw-r--r--src/bootstrap/builder.rs1
-rw-r--r--src/bootstrap/lib.rs36
2 files changed, 30 insertions, 7 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index 5489b1bc66b..c8a85eae252 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 15bf831a148..c46c68e4d56 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,18 +345,39 @@ 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_sysroot = config.initial_rustc.parent().unwrap().parent().unwrap();
-        let initial_lld = initial_sysroot
-            .join("lib")
-            .join("rustlib")
-            .join(config.build)
-            .join("bin")
-            .join("rust-lld");
+        let initial_target_libdir_str = if config.dry_run {
+            "/dummy/lib/path/to/lib/".to_string()
+        } else {
+            output(
+                Command::new(&config.initial_rustc)
+                    .arg("--target")
+                    .arg(config.build)
+                    .arg("--print")
+                    .arg("target-libdir"),
+            )
+        };
+        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(),