This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ned.deily
Recipients benjamin.peterson, eric.araujo, georg.brandl, ned.deily, ronaldoussoren, teamnoir
Date 2012-02-07.04:48:31
SpamBayes Score 3.0332098e-10
Marked as misclassified No
Message-id <>
When building and installing C extension modules, distutils attempts to use the same compiler and some compiler options as Python itself was built with.  For the current (3.2.2 and 2.7.2) 64-bit/32-bit python installers, the standard Apple-supplied gcc-4.2 in Xcode 3.2.x on OS X 10.6 was used.  As of Xcode 4.2, now standard for OS X 10.7 and optional for OS X 10.6, Apple no longer ships gcc-4.2 in Xcode, in favor of clang and the transitional llvm-gcc.  Moving the entire Python build to another compiler is a major undertaking, requiring careful testing, which is underway.  A compiler change may well be deemed too risky for a bug-fix release.

In any case, we can no longer assume that the same build compiler will be available on most user systems.  While it is possible for the user to manually override the distutils defaults by setting the CC and LDSHARED environment variables properly, setting the latter is tedious.  For example, to manually override to clang, the following is currently needed:

  LDSHARED='clang -bundle -undefined dynamic_lookup \
    -arch i386 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -g'
  python ...

Attached is a patch that attempts to "do the right thing" for OS X.  First, if the default build compiler is gcc-4.2 and the compiler has not been explicitly overridden by defining CC, distutils will check for the presence of gcc-4.2 on the default path.  If gcc-4.2 is not found and if clang is found, it will automatically substitute clang as the build compiler.  Second, if CC is used to override the compiler selection but LDSHARED is not defined, distutils will substitute the CC value into the default LDSHARED value.  This allows simple one-line compiler overrides, like:

  CC=llvm-gcc python ...

To minimize the risk of unintended side effects, these changes would apply to OS X only.

I propose applying this patch to 3.2 (for 3.2.3) and 2.7 (for 2.7.3) as well as provisionally to default for 3.3; a second patch will be needed with similar changes to packaging.  After the evaluation of compiler alternatives is complete and we decide what to do for 3.3, this approach might change.
Date User Action Args
2012-02-07 04:48:35ned.deilysetrecipients: + ned.deily, georg.brandl, ronaldoussoren, benjamin.peterson, eric.araujo, teamnoir
2012-02-07 04:48:35ned.deilysetmessageid: <>
2012-02-07 04:48:34ned.deilylinkissue13590 messages
2012-02-07 04:48:33ned.deilycreate