llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.22k stars 11.64k forks source link

llvm-ranlib fails to convert an archive with MacOS fat object files into a fat archive #94743

Open altalk23 opened 3 months ago

altalk23 commented 3 months ago

Tested with llvm 17.0.6 and 18.1.6, both of them seem to have the same issue.

  1. Given an archive with a fat object file Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit object x86_64Mach-O 64-bit object x86_64] [arm64:Mach-O 64-bit object arm64Mach-O 64-bit object arm64]
  2. Archived with ar using ar qc archive.a object.o (both Apple's ar and llvm-ar works fine in this step)
  3. Running llvm-ranlib archive.a fails to split the fat object file and create a fat archive, Running cmp on oldarchive.a and archive.a it tells me that only the metadata changes:
     25  61  60
     26  67  40
     27  61  40
     28  67  40
     29  67  40
     30  65  40
     31  65  40
     32  65  40
     33  60  40
     34  71  40
     37  65  60
     38  60  40
     39  61  40
     43  62  60
     44  60  40
     49  61  66
     50  60  64
     51  60  64
     52  66  40
     53  64  40
     54  64  40

    This behavior is different than Apple's ranlib, which does create the fat archive as expected.

Let me know if anything else is needed.

llvmbot commented 3 months ago

@llvm/issue-subscribers-tools-llvm-ar-llvm-ranlib

Author: alk (altalk23)

Tested with llvm 17.0.6 and 18.1.6, both of them seem to have the same issue. 1. Given an archive with a fat object file `Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit object x86_64Mach-O 64-bit object x86_64] [arm64:Mach-O 64-bit object arm64Mach-O 64-bit object arm64]` 2. Archived with ar using `ar qc archive.a object.o` (both Apple's ar and llvm-ar works fine in this step) 3. Running `llvm-ranlib archive.a` fails to split the fat object file and create a fat archive, Running `cmp` on oldarchive.a and archive.a it tells me that only the metadata changes: ``` 20 40 57 25 61 60 26 67 40 27 61 40 28 67 40 29 67 40 30 65 40 31 65 40 32 65 40 33 60 40 34 71 40 37 65 60 38 60 40 39 61 40 43 62 60 44 60 40 49 61 66 50 60 64 51 60 64 52 66 40 53 64 40 54 64 40 ``` This behavior is different than Apple's ranlib, which does create the fat archive as expected. Let me know if anything else is needed.