diff options
author | Ronald Oussoren <ronaldoussoren@mac.com> | 2008-06-05 12:58:24 (GMT) |
---|---|---|
committer | Ronald Oussoren <ronaldoussoren@mac.com> | 2008-06-05 12:58:24 (GMT) |
commit | 5640ce2f1edc0148ee14fd3daeb7ac700700bb71 (patch) | |
tree | 9bc8b41710d3a86ccbb579a0209928d787386b69 /setup.py | |
parent | 80af6da7489c3b28e0a46c73849da34273972e3b (diff) | |
download | cpython-5640ce2f1edc0148ee14fd3daeb7ac700700bb71.zip cpython-5640ce2f1edc0148ee14fd3daeb7ac700700bb71.tar.gz cpython-5640ce2f1edc0148ee14fd3daeb7ac700700bb71.tar.bz2 |
MacOS X: Enable 4-way universal builds
This patch adds a new configure argument on OSX:
--with-universal-archs=[32-bit|64-bit|all]
When used with the --enable-universalsdk option this controls which
CPU architectures are includes in the framework. The default is 32-bit,
meaning i386 and ppc. The most useful alternative is 'all', which includes
all 4 CPU architectures supported by MacOS X (i386, ppc, x86_64 and ppc64).
This includes limited support for the Carbon bindings in 64-bit mode as well,
limited because (a) I haven't done extensive testing and (b) a large portion
of the Carbon API's aren't available in 64-bit mode anyway.
I've also duplicated a feature of Apple's build of python: setting the
environment variable 'ARCHFLAGS' controls the '-arch' flags used for building
extensions using distutils.
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 53 |
1 files changed, 50 insertions, 3 deletions
@@ -248,6 +248,19 @@ class PyBuildExt(build_ext): 'WARNING: skipping import check for Carbon-based "%s"' % ext.name) return + + if self.get_platform() == 'darwin' and ( + sys.maxint > 2**32 and '-arch' in ext.extra_link_args): + # Don't bother doing an import check when an extension was + # build with an explicit '-arch' flag on OSX. That's currently + # only used to build 32-bit only extensions in a 4-way + # universal build and loading 32-bit code into a 64-bit + # process will fail. + self.announce( + 'WARNING: skipping import check for "%s"' % + ext.name) + return + # Workaround for Cygwin: Cygwin currently has fork issues when many # modules have been imported if self.get_platform() == 'cygwin': @@ -541,10 +554,12 @@ class PyBuildExt(build_ext): # readline do_readline = self.compiler.find_library_file(lib_dirs, 'readline') - if platform == 'darwin': + if platform == 'darwin': # and os.uname()[2] < '9.': # MacOSX 10.4 has a broken readline. Don't try to build # the readline module unless the user has installed a fixed # readline package + # FIXME: The readline emulation on 10.5 is better, but the + # readline module doesn't compile out of the box. if find_file('readline/rlconf.h', inc_dirs, []) is None: do_readline = False if do_readline: @@ -1304,11 +1319,24 @@ class PyBuildExt(build_ext): '_Dlg', '_Drag', '_Evt', '_File', '_Folder', '_Fm', '_Help', '_Icn', '_IBCarbon', '_List', '_Menu', '_Mlte', '_OSA', '_Res', '_Qd', '_Qdoffs', - '_Scrap', '_Snd', '_TE', '_Win', + '_Scrap', '_Snd', '_TE', ] for name in CARBON_EXTS: addMacExtension(name, carbon_kwds) + # Workaround for a bug in the version of gcc shipped with Xcode 3. + # The _Win extension should build just like the other Carbon extensions, but + # this actually results in a hard crash of the linker. + # + if '-arch ppc64' in cflags and '-arch ppc' in cflags: + win_kwds = {'extra_compile_args': carbon_extra_compile_args + ['-arch', 'i386', '-arch', 'ppc'], + 'extra_link_args': ['-framework', 'Carbon', '-arch', 'i386', '-arch', 'ppc'], + } + addMacExtension('_Win', win_kwds) + else: + addMacExtension('_Win', carbon_kwds) + + # Application Services & QuickTime app_kwds = {'extra_compile_args': carbon_extra_compile_args, 'extra_link_args': ['-framework','ApplicationServices'], @@ -1375,11 +1403,29 @@ class PyBuildExt(build_ext): include_dirs.append('/usr/X11R6/include') frameworks = ['-framework', 'Tcl', '-framework', 'Tk'] + # All existing framework builds of Tcl/Tk don't support 64-bit + # architectures. + cflags = sysconfig.get_config_vars('CFLAGS')[0] + archs = re.findall('-arch\s+(\w+)', cflags) + if 'x86_64' in archs or 'ppc64' in archs: + try: + archs.remove('x86_64') + except ValueError: + pass + try: + archs.remove('ppc64') + except ValueError: + pass + + for a in archs: + frameworks.append('-arch') + frameworks.append(a) + ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'], define_macros=[('WITH_APPINIT', 1)], include_dirs = include_dirs, libraries = [], - extra_compile_args = frameworks, + extra_compile_args = frameworks[2:], extra_link_args = frameworks, ) self.extensions.append(ext) @@ -1510,6 +1556,7 @@ class PyBuildExt(build_ext): '_ctypes', 'libffi_osx')) sources = [os.path.join(ffi_srcdir, p) for p in ['ffi.c', + 'x86/darwin64.S', 'x86/x86-darwin.S', 'x86/x86-ffi_darwin.c', 'x86/x86-ffi64.c', |