Can you build an OSX program supporting i386, x86_64 and PPC at the same time?
If you use Xcode, you don't have to use lipo, just list those architectures in the Architectures [ARCHS] build setting. Of course, you can't use Xcode 4, as it does not support ppc.
The answer would seem to be yes, you combine them all with the lipo tool.
Related
I would like to assemble Aarch64 armv8 Assembly on my mac and eventually run it with qemu and maybe on a real device like a raspberry pi 2 or 4 later on. I don't know how to assemble the code I'm going to write, gcc, llvm-gcc and clang don't seem to support the -arch=armv8 flag or anything similar. So I can't build for the targeted architecture, how could I achieve this?
I'm running mac os 10.14.5. I wouldn't mind finding a solution that works on a recent ubuntu version either since I have a VM for linux development.
The clang version that ships with Xcode supports -arch arm64. (Or armv7 for 32bit.)
Note that if you want to use any libraries though, they'll have to be arm64 as well. If you want, you can invoke the iOS toolchain with xcrun -sdk iphoneos clang -arch arm64 [...], but then you'll also have to pull the libraries you want off of some IPSW and stuff them into qemu.
Also note that the above will give you a Mach-O binary. For your Raspberry Pi, you'll probably want an ELF, and you'll probably want gcc rather than clang. You should be able to build both gcc and GNU binutils from source with --target as either aarch64-linux-gnu or aarch64-none-elf, depending on your goals. Yet another note: since macOS silently aliases gcc to clang and many tools depend on that, you'll probably also want to build this toolchain with something like --program-prefix=aarch64-.
Please help me with issue I break my neck with..
I work with Xcode 4.5.* and I try to build a library with Build Settings:
Architectures: 32-bit Intel
Valid Architectures: *i386 & x86_64*
But after checking the library details with lipo command I see that the actual library is built only for i386
Now I know this works in Xcode <=4.3 - the library is built for both architectures
Thanks
Roman
Now i add growl notification support into my app ,when i submitted it to mac app store with organizer,it says that
"
Unsupported Architecture - Application executables may support either or both of the Intel architectures:
i386 (32-bit)
x86_64 (64-bit)
"
Finally i find that its issue by growl library, so i need to remove the ppc section in growl,so,how to?
Please help..
Use the lipo command line utility, which strips architectures off fat binaries (what an appropriate name). First, check which architectures there are in your Growl framework:
$ lipo -info path/to/Growl.framework/Growl
Architectures in the fat file: Growl are: x86_64 i386 ppc
In this case, we simply have ppc, but there are about 10 variants (of which I've met 3). To avoid any surprise, you should run this command any time you want to strip architectures from a file instead of just jumping to the removal part. (If you're curious, man 3 arch has the exhaustive list of possible architectures for fat binaries on Mac OS.)
Then, remove the ppc achitecture:
$ lipo -remove ppc path/to/Growl.framework/Growl -output GrowlIntel
Find the real Growl binary (should be under Versions somewhere) and replace it with GrowlIntel.
You can also use "ditto". I submitted my last Mac app with frameworks included that are stripped off ppc support using the two below commands. No rejections from Apple.
$ ditto -rsrc --arch i386 --arch x86_64 Growl-WithInstaller Growl-WithInstaller_noppc
$ lipo -info Growl-WithInstaller_noppc
I'm trying to compile only for 32bit and 64bit. No matter what I choose in Xcode, I can either compile for 64bit or for 32bit, 64bit and ppc. I don't want ppc at all. Anyone has any idea how to compile for 32 & 64bit only?
Thanks!
In the Architectures setting for the project just set it explicitly to i386 and x86_64 rather than using the preset options.
To compile only for i386 and x86_64 (i.e. Intel) and not PPC, do the following:
Go to Project|Edit Project Settings
Select Build tab
In Architectures, do
not select any of the standard given
options such as Standard (32/64-bit
Universal) as these will always
throw in ppc. Select Other... and
add i386 and x86_64 manually.
In Valid Architectures, make it the same as Architectures (i.e. i386 and x86_64).
Compile. Test with lipo command in shell. (lipo -info test.app/Contents/MacOS/test) It should only say x86_64 i386 for architectures in file.
If that's not the case, then:
Go to Project|Edit Active Target "your app name" and do the same changes you did above, adding i386 and x86_64 manually.
Compile and test with lipo. It should say it's x86_64 i386 only.
I would like to know how you can support i386 and ppc architectures for programs at /bin.
I run for instance
bin $ file amber
I get
amber: setgid Mach-O universal binary with 2 architectures
amber (for architecture i386): Mach-O executable i386
amber (for architecture ppc): Mach-O executable ppc
How do programs support i386 and ppc in the source code?
In other words, which components can you remove, for instance, in /bin/amber if you remove the support of ppc -architecture?
It's called a Universal binary. In short, the executable contains both types of executable code. Apple has a published document describing how developers should build their applications to run on either platform.
The executable lipo can be used to remove either version of the executable from the file. If you want your executables to contain only one version, you can use lipo to achieve this.
Be aware that there is more than just ppc and i386, although these are the "safest" architectures to choose for a Universal binary. Read the manpage for arch; there you can see that a modern OSX binary is likely to contain any of ppc, ppc64, i386 or x86_64. There are many more listed, but they exist there for completeness.
It's called a fat binary.
There's a copy of the native code for both architectures in the binary. The binary format and the operating system have to support it, so it can know where to look in the file for the correct code.