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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 2.7
    • None
    • None

    Description

      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

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: