Issue #18080: When building a C extension module on OS X, if the compiler
is overriden with the CC environment variable, use the new compiler as
the default for linking if LDSHARED is not also overriden. This restores
Distutils behavior introduced in 2.7.3 and inadvertently dropped in 2.7.4.
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
index 0c726d9..4aa9334 100644
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -175,9 +175,15 @@
'CCSHARED', 'LDSHARED', 'SO', 'AR',
'ARFLAGS')
- newcc = None
if 'CC' in os.environ:
- cc = os.environ['CC']
+ newcc = os.environ['CC']
+ if (sys.platform == 'darwin'
+ and 'LDSHARED' not in os.environ
+ and ldshared.startswith(cc)):
+ # On OS X, if CC is overridden, use that as the default
+ # command for LDSHARED as well
+ ldshared = newcc + ldshared[len(cc):]
+ cc = newcc
if 'CXX' in os.environ:
cxx = os.environ['CXX']
if 'LDSHARED' in os.environ: