• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Universal binary command line build for different SDKs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Universal binary command line build for different SDKs


  • Subject: Re: Universal binary command line build for different SDKs
  • From: Syd Polk <email@hidden>
  • Date: Thu, 20 Jul 2006 17:43:02 -0500


On Jul 20, 2006, at 17:27 , Mike Cooper wrote:


We've got a large app which uses autoconf/make on multiple Unix/ Linux/etc platforms and are trying to build Universal binaries on Mac now.


We need to build for MacOS 10.3 for PPC and MacOS 10.4 for i386. What cc and ld command line options do we use to accomplish this?

This URL:

http://developer.apple.com/documentation/Porting/Conceptual/ PortingUnix/index.html

says to use

CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386" LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk - arch ppc -arch i386"

But this just builds a 10.4 universal and we need to target 10.3 for ppc for backwards compat.

Is there a means to specify in a single cc invocation per .c file to build a .o file for both 10.3/PPC and 10.4/i386? Or do we need to invoke cc twice for each .c file - once with the 10.3/PPC options based on the above and once again for the 10.4/i386 options? The later is going to wreck havoc with our existing autoconf/make system.

Thanks in advance.

mike

Since you general do configure-based builds in separate build directories, I recommend building for one platform in one directory, building for the other in a second directory, and then lipo'ing all of your binaries together in a third step. This is essentially how gcc and the like are built. The --exec-prefix in a properly- implemented auto-confiscated project can also help, putting all of the binaries in platform-specific directories.


So, do something like:

mkdir build install
cd build
mkdir ppc
cd ppc
$(SRC_DIR)/configure --target=powerpc-apple-darwin8 -CFLAGS="- isysroot /Developer/SDKs/MacOSXSDK10.4u.sdk" -arch ppc LDFLAGS="-Wl,- syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch ppc" - prefix=`pwd`../../install --exec-prefix=`pwd`/../../install/ppc
make
make install
cd ..
mkdir i386
cd i386
$(SRC_DIR)/configure --target=i386-apple-darwin8 -CFLAGS="-isysroot / Developer/SDKs/MacOSXSDK10.4u.sdk" -arch i386 LDFLAGS="-Wl,- syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch i386" - prefix=`pwd`/../../install --exec-prefix=`pwd`/../../install/i386
make
make install
cd ..
cd ..
# Now, your installation will be in ./install, with your binaries in ./install/ppc and ./install/i386
lipo ./install/ppc/foo ./install/i386/foo -output ./install/foo


Or some such.

It's much easier to do this than to try to get "-arch ppc -arch i386" to work throughout autoconf/automake/libtool/configure/whatever.

It's not free; there is work involved, and it's non-trivial. You also have to watch for host-platform assumptions. If you build on a i386 machine, and a configure test says that a certain capability exists on that machine, but the target is actually a powerpc machine, you will have problems. The configure.ac files need to be bulletproof, and need to actually work when you specify --target; otherwise you may end up with problems ranging from compilation to subtle runtime problems.


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com


This email sent to email@hidden

Syd Polk - email@hidden "Let the music be your light." -- Dave Edwards, KUHF-FM, 1982



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Universal binary command line build for different SDKs (From: Mike Cooper <email@hidden>)

  • Prev by Date: Universal binary command line build for different SDKs
  • Next by Date: How can I change subclasses in InterfaceBuilder easily with a custom classInspector ?
  • Previous by thread: Universal binary command line build for different SDKs
  • Next by thread: How can I change subclasses in InterfaceBuilder easily with a custom classInspector ?
  • Index(es):
    • Date
    • Thread