Work around Xcode 5.1 build issues PYTHON-654

This patch attempts to work around the unrecognized
cflag errors raised by clang 3.4 - shipped with Xcode 5.1.
This commit is contained in:
Bernie Hackett 2014-03-13 16:06:12 -07:00
parent 97be203bf9
commit f1637f1ebf
2 changed files with 38 additions and 0 deletions

View File

@ -95,6 +95,26 @@ versions of Python 2.7 >= 2.7.4 or Python 3.x >= 3.2.4 downloaded from
python.org. In all cases Xcode must be installed with 'UNIX Development
Support'.
**Xcode 5.1**: Starting with version 5.1 the version of clang that ships with
Xcode throws an error when it encounters compiler flags it doesn't recognize.
This may cause C extension builds to fail with an error similar to::
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
There are workarounds::
# Apple specified workaround for Xcode 5.1
# easy_install
$ ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future easy_install pymongo
# or pip
$ ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pymongo
# Alternative workaround using CFLAGS
# easy_install
$ CFLAGS=-Qunused-arguments easy_install pymongo
# or pip
$ CFLAGS=-Qunused-arguments pip install pymongo
Installing from source
----------------------

View File

@ -1,5 +1,7 @@
import glob
import os
import platform
import re
import subprocess
import sys
import warnings
@ -44,6 +46,22 @@ finally:
PY3 = sys.version_info[0] == 3
# PYTHON-654 - Clang doesn't support -mno-fused-madd but the pythons Apple
# ships are built with it. This is a problem starting with Xcode 5.1
# since clang 3.4 errors out when it encounters unrecognized compiler
# flags. This hack removes -mno-fused-madd from the CFLAGS automatically
# generated by distutils for Apple provided pythons, allowing C extension
# builds to complete without error. The inspiration comes from older
# versions of distutils.sysconfig.get_config_vars.
if sys.platform == 'darwin' and 'clang' in platform.python_compiler().lower():
from distutils.sysconfig import get_config_vars
res = get_config_vars()
for key in ('CFLAGS', 'PY_CFLAGS'):
if key in res:
flags = res[key]
flags = re.sub('-mno-fused-madd', '', flags)
res[key] = flags
nose_config_options = {
'with-xunit': '1', # Write out nosetests.xml for CI.
'py3where': 'build', # Tell nose where to find tests under PY3.