Quellcode durchsuchen

fix: use system ranlib (#4163)

Jonathan Kelley vor 1 Monat
Ursprung
Commit
e719f9c7c4
1 geänderte Dateien mit 14 neuen und 0 gelöschten Zeilen
  1. 14 0
      packages/cli/src/build/request.rs

+ 14 - 0
packages/cli/src/build/request.rs

@@ -1582,6 +1582,13 @@ impl BuildRequest {
             let bytes = out_ar.into_inner().context("Failed to finalize archive")?;
             std::fs::write(&out_ar_path, bytes).context("Failed to write archive")?;
             tracing::debug!("Wrote fat archive to {:?}", out_ar_path);
+
+            // Run the ranlib command to index the archive. This slows down this process a bit,
+            // but is necessary for some linkers to work properly.
+            // We ignore its error in case it doesn't recognize the architecture
+            if let Some(ranlib) = self.select_ranlib() {
+                _ = Command::new(ranlib).arg(&out_ar_path).output().await;
+            }
         }
 
         compiler_rlibs.dedup();
@@ -3937,4 +3944,11 @@ r#" <script>
 
         Ok(())
     }
+
+    fn select_ranlib(&self) -> Option<PathBuf> {
+        // prefer the modern llvm-ranlib if they have it
+        which::which("llvm-ranlib")
+            .or_else(|_| which::which("ranlib"))
+            .ok()
+    }
 }