about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/back/archive.rs
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-01-27 11:46:27 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-01-27 11:46:27 +0000
commit2cf101c3e7d5fffab8f72b1e04224bc3bc2d9e02 (patch)
treec6d3f56ed9f2d47453ed01cab28d35e4b3eb8773 /compiler/rustc_codegen_llvm/src/back/archive.rs
parentb2e298853113e9b9d68c956749d92ad540fb286d (diff)
downloadrust-2cf101c3e7d5fffab8f72b1e04224bc3bc2d9e02.tar.gz
rust-2cf101c3e7d5fffab8f72b1e04224bc3bc2d9e02.zip
Revert "Remove macOS fat archive support from LlvmArchiveBuilder"
This reverts commit 047c7cc60c05e2cf182c6f578581cf2a67b1d0ff.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/back/archive.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/back/archive.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_llvm/src/back/archive.rs b/compiler/rustc_codegen_llvm/src/back/archive.rs
index 426f57c0608..b00676b7c59 100644
--- a/compiler/rustc_codegen_llvm/src/back/archive.rs
+++ b/compiler/rustc_codegen_llvm/src/back/archive.rs
@@ -15,8 +15,8 @@ use crate::errors::{
 use crate::llvm::archive_ro::{ArchiveRO, Child};
 use crate::llvm::{self, ArchiveKind, LLVMMachineType, LLVMRustCOFFShortExport};
 use rustc_codegen_ssa::back::archive::{
-    get_native_object_symbols, ArArchiveBuilder, ArchiveBuildFailure, ArchiveBuilder,
-    ArchiveBuilderBuilder, UnknownArchiveKind,
+    get_native_object_symbols, try_extract_macho_fat_archive, ArArchiveBuilder,
+    ArchiveBuildFailure, ArchiveBuilder, ArchiveBuilderBuilder, UnknownArchiveKind,
 };
 
 use rustc_session::cstore::DllImport;
@@ -66,7 +66,13 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
         archive: &Path,
         skip: Box<dyn FnMut(&str) -> bool + 'static>,
     ) -> io::Result<()> {
-        let archive_ro = match ArchiveRO::open(archive) {
+        let mut archive = archive.to_path_buf();
+        if self.sess.target.llvm_target.contains("-apple-macosx") {
+            if let Some(new_archive) = try_extract_macho_fat_archive(&self.sess, &archive)? {
+                archive = new_archive
+            }
+        }
+        let archive_ro = match ArchiveRO::open(&archive) {
             Ok(ar) => ar,
             Err(e) => return Err(io::Error::new(io::ErrorKind::Other, e)),
         };
@@ -74,7 +80,7 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
             return Ok(());
         }
         self.additions.push(Addition::Archive {
-            path: archive.to_path_buf(),
+            path: archive,
             archive: archive_ro,
             skip: Box::new(skip),
         });