lipo deletes Bitcode segments when merging iOS and OS X code

Originator:greg
Number:rdar://21826157 Date Originated:2015-07-14
Status:Resolved Resolved:2015-07-15
Product:Developer Tools Product Version:7S152u / 15A216g
Classification:Crash / Hang / Data Loss Reproducible:Always
 
I am mistaken. It's strange that the results of otool -l vary for a binary which includes just arm64 and armv7 targets versus when a binary includes arm64, armv7, i386, and x86_64. In the first case, otool -l prints a header indicating the architecture and then its details. In the second case, otool -l prints a header with no indication of the architecture, followed by what would be printed if one calls otool -arch arm64 -l, but without the __bundle / __LLVM section.

I'm able to verify the presence of bitcode in the universal binary by running:

otool -arch arm64 -l ~/Desktop/MissingBitcode | grep __LLVM
otool -arch armv7 -l ~/Desktop/MissingBitcode | grep __LLVM
This issue has been verified as resolved and can be closed.

Summary:
lipo deletes Bitcode segments when merging iOS and OS X code, as one might do in order to ship a single .framework which can be used for both the devices and the Simulator. We ship armv7, arm64, i386, and x86_64 in our TextExpander.framework's binary. We do this by building the iOS and OS X versions separately and using lipo to merge the binaries.

Steps to Reproduce:
Using OS X 10.11 Beta 3 (15A216g):

1. In Terminal, run:

sudo xcode-select -s /Applications/Xcode-beta.app/

2. Download the attached files: TextExpander_iOS_with_bitcode and TextExpander_OSX and place them on your Desktop

3. Validate that TextExpander_iOS_with_bitcode contains Bitcode by running this in Terminal:

otool -l ~/Desktop/TextExpander_iOS_with_bitcode | grep __LLVM

The result should be:

    segname __LLVM
    segname __LLVM

These are the bitcode segments for armv7 and arm64.

4. Merge the OS X code by running this in Terminal:

cd ~/Desktop
lipo -create TextExpander_iOS_with_bitcode TextExpander_OSX -output MissingBitcode

5. Validate that the merged MissingBitcode contains Bitcode by running this in Terminal:

otool -l MissingBitcode | grep __LLVM


Expected Results:
Expected result from step #5:
    segname __LLVM
    segname __LLVM


Actual Results:
Actual result from step #5:
(Nothing. No matches.)

Using lipo to merge iOS and OS X code strips the Bitcode segments from the iOS code.

Version:
Xcode 7.0 beta 3 (7A152u)
OS X 10.11 Beta 3 (15A216g)

Notes:


Configuration:
MacBook Pro (Retina, 15-inch, Late 2013)
2.6 GHz Intel Core i7
16 GB 1600 MHz DDR3
NVIDIA GeForce GT 750M 2048 MB

Attachments:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!