Skip to content
Merged
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
14 changes: 14 additions & 0 deletions packages/cli/src/build/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,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();
Expand Down Expand Up @@ -3961,4 +3968,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()
}
}
Loading