OS X: GCC, Clang, and Cython in 10.9 Mavericks

(Revised March 10, 2015)

Starting with Xcode version 5 (released with OS X 10.9 Mavericks), Apple has removed support for gcc, such that gcc is no longer actually the GNU Compiler Collection, but is symlinked to the  clang compiler.

Users still hoping to access a C compiler for their projects, such as in building C-extensions using Cython, should generally not run into any problems in using the symlinked gcc (or directly using clang), as clang uses the same LLVM backend and libraries as Apple's previous gcc compiler.

However, if you are building a C++ library (via clang++) that you will later link with a Python extension, or if you are building a Python extension that uses a C++ library, you need to use the older libraries (libstdc++, and not the clang++ default of libc++) via these compiler/linker flags: -stdlib=libstdc++ -mmacosx-version-min=10.6

As it may be preferable for some users, it is still possible to install and use Xcode 4.6.3 on OSX 10.9 by searching around on developer.apple.com. Please note that these developer tools do not include the 10.9 SDK.

Have more questions? Submit a request


  • Avatar
    Jonathan March

    Sturla Molden writes (Thanks, Sturla, we will update ASAP):

    This is very misleading. From my understanding, this is what we need to know about building C extensions on Mavericks and Xcode 5 with command line tools:

    1. Apple's former llvm-gcc used LLVM as backend, and so does clang. Only the C++ standard library has changed.

    2. Do not use MacPorts or Homebrew to reinstall GCC! It will use GCC as backend, not LLVM, and will not be binary compatible with Apple's llvm-gcc! Reinstalling GCC this way would be the worst thing to do, but Weaver recommends it.

    3. Intel C++ Composer XE is binary compatible with llvm-gcc. Just export CC=icc and CXX=icpc and you will be safe.

    4. The only thing that has changed at binary level is the standard C++ library. Unless you need to link the same C++ library as Canopy, I would say just use clang from Xcode 5. It is very unlikely to break. The C compiler uses the same backend and libraries as llvm-gcc and should be binary compatible.

  • Avatar
    Sturla Molden

    Here are some extra information I think might be useful:

    • To make clang++ produce binaries compatible with g++ from llvm-gcc-4.2.1, use these compiler and linker flags: -stdlib=libstdc++ -mmacosx-version-min=10.6 These will make sure we link with the 10.6 CRT and that we do not link with libc++ (the default C++ library for clang++).

    • For the clang C compiler, note that the 10.9 SDK has crt1.10.6.o after Xcode 5 command line tools are installed. That means passing -mmacosx-version-min=10.6 to the C compiler and linker will make sure the same CRT as Canopy is linked. We do not need to use the 10.6 SDK as -isysroot for this.

    Two side notes:

    • clang and clang++ are better compilers than llvm-gcc-4.2.1 because they support C99 and C++11. The demise of llvm-gcc-4.2.1 should be welcomed.
    • Because crt1.10.6.o is required for binary compatibility with llvm-gcc-4.2.1, **Intel C++ Composer XE requires the Xcode 5 command line tools **to be installed: http://software.intel.com/en-us/forums/topic/494768







  • Avatar
    Sturla Molden

    Intel released a service pack to their compilers and to MKL two days ago. They are now claiming to be Mavericks compatible.

  • Avatar
    Sturla Molden

    Cython got an important bugfix today. It is required for building C++ extensions with the Xcode 5 toolset.

  • Avatar
    Jordan Weaver

    Thanks for all the information, Sturla! I've made some updates to the article based on your very helpful suggestions and my discussions with our developers.

  • Avatar
    Sturla Molden

    If you have problems building C++ extensions with Cython on Mavericks, make sure you have this patch in your Cython:


    Currently this means go and get Cython master from GitHub. There is no release with this patch yet.

    Explanation: Cython uses "placement new" to put C++ objects inside memory managed by Python. This means that Cython must call destructors explicitely before the memory is freed, as C++ has no "placement delete". There is a bug or C++ standard pedantry (still a matter of dispute) in the resolution of destructor calls in clang++, the most common C++ compiler on Mavericks. This means that code like std::string::~string() will not compile on Mavericks, unless we use a different C++ compiler. Cython now uses a small utility function that works around this namespace resolution bug/peculiarity with a C++ template.

    (BTW: Other C++ projects has been affected too, such as Mozilla Firefox.)

  • Avatar
    mike bla

    I get tons of errors alike:

    expected initializer before '__AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_9'

    on Mavericks with xcode 4.6.3

    Thanks for any help



Powered by Zendesk