Skip to content

Commit

Permalink
override ldshared on non-macos platforms too if CC is overriden
Browse files Browse the repository at this point in the history
  • Loading branch information
isuruf committed Sep 16, 2021
1 parent 887749a commit 10988e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions distutils/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,9 @@ def customize_compiler(compiler):

if 'CC' in os.environ:
newcc = os.environ['CC']
if (sys.platform == 'darwin'
and 'LDSHARED' not in os.environ
if('LDSHARED' not in os.environ
and ldshared.startswith(cc)):
# On OS X, if CC is overridden, use that as the default
# If CC is overridden, use that as the default
# command for LDSHARED as well
ldshared = newcc + ldshared[len(cc):]
cc = newcc
Expand Down
8 changes: 4 additions & 4 deletions distutils/tests/test_unixccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ def gcv(v):
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):
@unittest.skipIf(sys.platform == 'win32', "can't test on Windows")
def test_cc_overrides_ldshared(self):
# Issue #18080:
# ensure that setting CC env variable also changes default linker
def gcv(v):
Expand All @@ -202,8 +202,8 @@ def gcvs(*args, _orig=sysconfig.get_config_vars):
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_explicit_ldshared(self):
@unittest.skipIf(sys.platform == 'win32', "can't test on Windows")
def test_explicit_ldshared(self):
# Issue #18080:
# ensure that setting CC env variable does not change
# explicit LDSHARED setting for linker
Expand Down

0 comments on commit 10988e0

Please sign in to comment.