I'm porting a C/C++ library using the library's makefile. The library includes a test suite and I'm having some trouble getting the EXE to work as expected when only using a single architecture. Below is a sample produced by the makefile's recipe (formatting added for readability):
$ export IOS_PLATFORM=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
$ make static dynamic cryptest.exe
clang++ -DNDEBUG -g -Os -pipe -fPIC -arch armv7
--sysroot $(IOS_PLATFORM)/Developer/SDKs/iPhoneOS6.1.sdk
-miphoneos-version-min=5.0 -DCRYPTOPP_DISABLE_ASM=1 -c 3way.cpp
clang++ -DNDEBUG -g -Os -pipe -fPIC -arch armv7
--sysroot $(IOS_PLATFORM)/Developer/SDKs/iPhoneOS6.1.sdk
-miphoneos-version-min=5.0 -DCRYPTOPP_DISABLE_ASM=1 -c adler32.cpp
...
IF I build the EXE with a single architecture (armv7
) as above, then running the executable results in "Bad CPU Type In Executable." file
tells me its a Mach-O but not Universal:
$ file cryptest.exe
cryptest.exe: Mach-O executable arm
IF I build for multiple architectures (armv7
and armv7s
), then the program runs as expected.
IF I build for multiple architectures (armv7
and armv7s
) and strip an architecture, then the program runs as expected:
$ 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.bu
cryptest.exe.bu: Mach-O universal binary with 2 architectures
cryptest.exe.bu (for architecture armv7): Mach-O executable arm
cryptest.exe.bu (for architecture armv7s): Mach-O executable arm
$ file cryptest.exe
cryptest.exe: Mach-O universal binary with 1 architecture
cryptest.exe (for architecture armv7): Mach-O executable arm
Is it possible to instruct Apple's command line tools to build a binary with the extra universal headers even though its only single arch (to save the extra work of removing the unused architecture)?