Ned Deily <n...@acm.org> added the comment:

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:

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

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 setup.py ...

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.

----------
keywords: +patch
stage:  -> patch review
Added file: http://bugs.python.org/file24442/issue13590_distutils.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13590>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to