Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-654

Xcode 5.1 (clang 3.4) breaks C extension builds on Apple provided pythons

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.7
    • Affects Version/s: None
    • Component/s: None
    • None

      When python C extensions are built distutils uses the same compiler / linker flags that were used to build the python interpreter itself. The interpreters provided by Apple in OSX (python 2.5, 2.6, and 2.7) were built with -mno-fused-madd. Clang doesn't support that flag and Apple has never fixed their interpreter builds to not use it. This hasn't been a problem in the past since previous versions of clang ignored unrecognized flags. Clang 3.4 changes the situation by erroring out when it encounters unrecognized flags.

      In classic Apple fashion no updated interpreters were provided with the Xcode 5.1 update so installation of packages with C extensions (e.g. pymongo, greenlet, gevent, simplejson, etc, etc, etc) fail with an error similar to this:

      clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
      

      PyMongo 2.7 will ship with a hack to work around the problem but in the meantime the following workarounds exist:

      pip:

      $ ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pymongo
       
      or
      
      $ CFLAGS=-Qunused-arguments pip install pymongo
      

      easy_install:

      $ ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future easy_install pymongo
      
      or
      
      $ CFLAGS=-Qunused-arguments easy_install pymongo
      

      If your python interpreter was built without -mno-fused-madd you won't have this problem to begin with. You can check what cflags were used to build python on OSX with the python-config tool:

      $ python-config --cflags
      

      See this stackoverflow thread for ongoing discussion:
      http://stackoverflow.com/questions/22313407/clang-error-unknown-argument-mno-fused-madd-psycopg2-installation-failure

      Xcode 5.1 release notes. See the "Compiler" section were this breakage is documented:
      https://developer.apple.com/library/ios/releasenotes/DeveloperTools/RN-Xcode/Introduction/Introduction.html

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            bernie@mongodb.com Bernie Hackett
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: