bdunagan

fill the void - bdunagan

15 Sep 2011
Compiling PowerPC with LLVM GCC 4.2 in Xcode 4.1 on 10.7

There have been a number of excellent articles describing how to restore various older technologies to Xcode 4 (10.4 SDK, 10.5 SDK, GCC 4.0, PPC). Thanks to mecki for doing such a good job detailing the steps. The only trouble is those steps didn’t work for me in one case: PowerPC support. Luckily, it’s easy to restore.

Here is the short C code I compiled to test the process:

#include <stdio.h>
main() { printf("Hello world\n"); return 0; }

I compiled the C code with LLVM GCC 4.2 (Xcode 4’s default compiler), specifying the PowerPC architecture with 10.6 SDK. Then I used lipo to check the binary’s architecture.

# Compile with PPC architecture.
/Developer/usr/bin/llvm-gcc-4.2 -arch ppc -isysroot /Developer/SDKs/MacOSX10.6.sdk main.c -o Hello
# Check the binary's architecture.
lipo -info Hello
# Should see: "Non-fat file: Hello is architecture: ppc7400"

I installed Xcode 4.1 on my 10.7 system and then copied files from Xcode 3.2.5 on my 10.6 system into /Xcode3 on my 10.7 system. Here are the files I included:

/Xcode3/usr/bin/as (51 KB)
/Xcode3/usr/libexec/gcc/darwin/ppc/as (466 KB)
/Xcode3/usr/llvm-gcc-4.2/* (130 MB)

Here are the shell commands that I used to finally get LLVM GCC 4.2 to compile with PowerPC:

cd /Developer/usr/llvm-gcc-4.2/bin
sudo ln -s /Xcode3/usr/llvm-gcc-4.2/bin/powerpc-apple-darwin10-llvm-gcc-4.2 powerpc-apple-darwin11-llvm-gcc-4.2

One last hurdle was Xcode 4’s build settings. I had to specify “ppc” not only in “Valid Architectures” but also in “Architectures”, along with $(ARCHS_STANDARD_32_64_BIT).

Xcode 4.3 Update: Restore 10.5 support simply by symlinking your existing 10.5 SDK to the following path inside Xcode.app:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
Previous LinkedIn Twitter GitHub Email Next