diff options
author | Ned Deily <nad@acm.org> | 2013-05-28 23:31:45 (GMT) |
---|---|---|
committer | Ned Deily <nad@acm.org> | 2013-05-28 23:31:45 (GMT) |
commit | 1ab29e78f9e61c86879fa8884a543022ea43112d (patch) | |
tree | 5c718ab533b2cdb84451e0414baba78c600e4608 /Lib/distutils/tests/test_unixccompiler.py | |
parent | 3fcf2d3174ebfc4b405b34bf7199451356fa51eb (diff) | |
download | cpython-1ab29e78f9e61c86879fa8884a543022ea43112d.zip cpython-1ab29e78f9e61c86879fa8884a543022ea43112d.tar.gz cpython-1ab29e78f9e61c86879fa8884a543022ea43112d.tar.bz2 |
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.
Diffstat (limited to 'Lib/distutils/tests/test_unixccompiler.py')
-rw-r--r-- | Lib/distutils/tests/test_unixccompiler.py | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/Lib/distutils/tests/test_unixccompiler.py b/Lib/distutils/tests/test_unixccompiler.py index 40c908a..64f9d26 100644 --- a/Lib/distutils/tests/test_unixccompiler.py +++ b/Lib/distutils/tests/test_unixccompiler.py @@ -1,7 +1,8 @@ """Tests for distutils.unixccompiler.""" +import os import sys import unittest -from test.test_support import run_unittest +from test.test_support import EnvironmentVarGuard, run_unittest from distutils import sysconfig from distutils.unixccompiler import UnixCCompiler @@ -122,6 +123,37 @@ class UnixCCompilerTestCase(unittest.TestCase): sysconfig.get_config_var = gcv self.assertEqual(self.cc.rpath_foo(), '-R/foo') + @unittest.skipUnless(sys.platform == 'darwin', 'test only relevant for OS X') + def test_osx_cc_overrides_ldshared(self): + # Issue #18080: + # ensure that setting CC env variable also changes default linker + def gcv(v): + if v == 'LDSHARED': + return 'gcc-4.2 -bundle -undefined dynamic_lookup ' + return 'gcc-4.2' + sysconfig.get_config_var = gcv + with EnvironmentVarGuard() as env: + env['CC'] = 'my_cc' + del env['LDSHARED'] + sysconfig.customize_compiler(self.cc) + self.assertEqual(self.cc.linker_so[0], 'my_cc') + + @unittest.skipUnless(sys.platform == 'darwin', 'test only relevant for OS X') + def test_osx_explict_ldshared(self): + # Issue #18080: + # ensure that setting CC env variable does not change + # explicit LDSHARED setting for linker + def gcv(v): + if v == 'LDSHARED': + return 'gcc-4.2 -bundle -undefined dynamic_lookup ' + return 'gcc-4.2' + sysconfig.get_config_var = gcv + with EnvironmentVarGuard() as env: + env['CC'] = 'my_cc' + env['LDSHARED'] = 'my_ld -bundle -dynamic' + sysconfig.customize_compiler(self.cc) + self.assertEqual(self.cc.linker_so[0], 'my_ld') + def test_suite(): return unittest.makeSuite(UnixCCompilerTestCase) |