1

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)?

4

1 に答える 1

1

ユニバーサル バイナリをビルドするためのスイッチを見つけることができませんでした。また、Apple が実行している Xcode の魔法を追跡することもできませんでした。非ユニバーサル バイナリ (単一アーキテクチャ) をビルドし、実行してユニバーサルを作成できることがわかりlipoました。

$ make cryptest.exe
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  
$ lipo -info cryptest.exe
Non-fat file: cryptest.exe is architecture: armv7
$ lipo cryptest.exe -create -output cryptest.exe
$ lipo -info cryptest.exe
Architectures in the fat file: cryptest.exe are: armv7 
于 2013-07-08T19:29:26.843 に答える