Compiling as 32bit on MacOSX

Ned Deily nad at acm.org
Wed Oct 13 04:32:37 CEST 2010


In article <8hkct2F31qU1 at mid.individual.net>,
 Gregory Ewing <greg.ewing at canterbury.ac.nz> wrote:
> I'm getting my Python environment set up on a new
> Snow Leopard machine, and I'd like to compile everything
> in 32 bit mode for the time being, because some of the
> extensions I need use APIs that aren't available in
> 64 bit.
> 
> Is there some environment variable or config setting
> that will make gcc compile 32 bit binaries by default?
> Setting CFLAGS isn't very reliable, since the build
> systems of some libraries don't seem to take notice
> of it.

It varies.  Projects that use one of the Apple-supplied gcc's (4.2 or 
4.0) generally use the -arch parameter.

For Python itself on 10.6, there isn't a standard configure option to 
build just for i386 (Intel 32-bit).  The two easiest choices are to 
either build for 32-bit only which results in a i386 and ppc universal 
build:

./configure MACOSX_DEPLOYMENT_TARGET=10.6 
--with-universal-archs="32-bit" 
--enable-universalsdk=/Developer/SDKs/MacOSX10.6.sdk

or tweak the configure options a bit which *should* result in an 
i386-only build (at least for 2.7 and 3.2):

./configure MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS="-arch i386" 
LDFLAGS="-arch i386"

If you want backwards compatibility, add or change the sdk and 
deployment target values ("10.5" "MacOSX10.5.sdk" or "10.4" 
"MacOSX10.4u.sdk" along with GCC=/usr/bin/gcc-4.0).  For a framework 
build, throw in --enable-framework.

Distutils should ensure that the right settings will get passed on to 
any extension module builds.

-- 
 Ned Deily,
 nad at acm.org




More information about the Python-list mailing list