/dev/random

Reality has a liberal bias

/dev/random random header image

Universal builds for PPC & x86

November 8th, 2005 · 5 Comments · Uncategorized

The latest version of XCode allows you to specify separate settings for x86 & PPC code, although it isn’t really obvious how to do it. After some digging I figured it out.

Some of the build settings such as SDKROOT & GCC_VERSION allow you to specify which architecture they apply to by appending _ppc or _i386 to the settings name. Here’s how I’m able to build a universal binary that will run on OS X 10.2 or later (which requires it to be built with GCC 3.3) as well as x86.

First, set up the project & target settings as required for building the x86 version. Then add the following variables to the build panel of the project or target settings window (hit the ‘+’ button to add a variable & edit the name).

MACOSX_DEPLOYMENT_TARGET_ppc  10.2
GCC_VERSION_ppc               3.3
SDKROOT_ppc                   /Developer/SDKs/MacOSX10.2.8.sdk

Those settings will override the defaults when building a PPC binary, while the defaults will be used when building x86.

Tags:

5 responses so far ↓

  • 1 Michael Tsai - Blog - Xcode 2.2 Universal Binaries // Nov 11, 2005 at 10:36 am

    [...] Mike Cohen shows how to use Xcode’s new per-architecture build settings to create Universal Binaries that run on Mac OS X 10.2. Shell script contortions are no longer necessary, except of course for libraries compiled outside of Xcode. [...]

  • 2 Jesper (1 comments.) // Nov 11, 2005 at 1:49 pm

    Architecture-dependent build settings aren’t new. I can confirm that SDKROOT was able to be tweaked in 2.1 already, and probably years before; earlier documentation refers to it as a way to compile for ppc64 (the G5), now 30 months old. (However, I don’t know if MACOSX_DEPLOYMENT_TARGET and GCC_VERSION are available on these older versions.)

  • 3 David Young (1 comments.) // Nov 20, 2005 at 8:18 pm

    GCC_VERSION is new, and it’s the key. Before that, you were stuck with separate build passes for gcc 4.0 and 3.3 on Intel/PPC, respectively, and lipo afterwards. Or, you could have done this unsupported hack,

  • 4 Jeremy’s Little Corner Of The Web… // Jan 5, 2006 at 1:32 pm

    links from Technorati »/dev/random: Universal builds for PPC & x86

  • 5 UsefulLinks - Xjournal - Trac // May 5, 2007 at 4:27 pm

    Kramer auto Pingback[...] History Useful Links Universal Builds for PPC and Intel Apple Universal Binary Programming Guidelines GCC 4.01 Porting Guide [...]