Re: Create Universal Binary with One Architecture?
Re: Create Universal Binary with One Architecture?
- Subject: Re: Create Universal Binary with One Architecture?
- From: Nick Blievers <email@hidden>
- Date: Sun, 07 Jul 2013 21:39:33 -0500
- Acceptlanguage: en-US
- Thread-topic: Create Universal Binary with One Architecture?
On 08/07/2013, at 12:29 PM, Jeffrey Walton wrote:
> Hi All,
>
> I need to create a universal binary from the command line. The twist
> is that I'm only using one architecture.
>
> Out of the box, it appears the command line tools create a non-fat executable:
>
> ...
> $clang++ -o cryptest.exe -DNDEBUG -g -Os -pipe -fPIC -arch armv7
> --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk
> -miphoneos-version-min=5.0 -DCRYPTOPP_DISABLE_ASM=1 bench.o bench2.o
> test.o validat1.o validat2.o validat3.o adhoc.o datatest.o regtest.o
> fipsalgt.o dlltest.o ./libcryptopp.a
> ...
>
> $ file cryptest.exe
> cryptest.exe: Mach-O executable arm
>
> If I use two architectures (armv7 and armv7s), then I get the universal binary:
>
> $ file cryptest.exe
> cryptest.exe: Mach-O universal binary with 2 architectures
> cryptest.exe (for architecture armv7): Mach-O executable arm
> cryptest.exe (for architecture armv7s): Mach-O executable arm
>
> If I strip the unwanted architecture, then I still have a universal binary:
>
> $ mv cryptest.exe cryptest.exe.bu
> $ xcrun -sdk iphoneos lipo cryptest.exe.bu -remove armv7s -output cryptest.exe
> $ codesign -fs "Jeffrey Walton" cryptest.exe
> cryptest.exe: replacing existing signature
> $ file cryptest.exe
> cryptest.exe: Mach-O universal binary with 1 architecture
> cryptest.exe (for architecture armv7): Mach-O executable arm
>
> How does one specify a universal binary, even if using one architecture?
You can look at what Xcode is doing based on the build output (all the command line options will be there). However, you could just use lipo on the single arch binary:
$ lipo -create -output test_fat test
$ file test_fat
test_fat: Mach-O universal binary with 1 architecture
test_fat (for architecture x86_64): Mach-O 64-bit executable x86_64
$
Nick
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden