Skip to content

Commit

Permalink
fix ldcxxshared with ccache
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Nov 13, 2024
1 parent 57ed6f0 commit 274020a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions newsfragments/4749.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix c++ linker arguments if python is compiled with ccache
10 changes: 6 additions & 4 deletions setuptools/_distutils/sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import re
import sys
import sysconfig
import shlex

from jaraco.functools import pass_none

Expand Down Expand Up @@ -64,7 +65,6 @@ def _is_parent(dir_a, dir_b):


if os.name == 'nt':

@pass_none
def _fix_pcbuild(d):
# In a venv, sys._home will be inside BASE_PREFIX rather than PREFIX.
Expand All @@ -88,7 +88,6 @@ def _python_build():

python_build = _python_build()


# Calculate the build qualifier flags if they are defined. Adding the flags
# to the include and lib directories only makes sense for an installation, not
# an in-source build.
Expand Down Expand Up @@ -328,11 +327,14 @@ def customize_compiler(compiler):
if 'LDSHARED' not in os.environ and ldshared.startswith(cc):
# If CC is overridden, use that as the default
# command for LDSHARED as well
ldshared = newcc + ldshared[len(cc) :]
ldshared = newcc + ldshared[len(cc):]
cc = newcc
cxx = os.environ.get('CXX', cxx)
ldshared = os.environ.get('LDSHARED', ldshared)
ldcxxshared = os.environ.get('LDCXXSHARED', ldcxxshared)
ldcxxshared_s = shlex.split(ldcxxshared)
if ldcxxshared_s[0] in {'ccache', 'sccache'}:
ldcxxshared = shlex.join(ldcxxshared_s[1:])
cpp = os.environ.get(
'CPP',
cc + " -E", # not always
Expand Down Expand Up @@ -481,7 +483,7 @@ def parse_makefile(fn, g=None): # noqa: C901
else:
done[n] = item = ""
if found:
after = value[m.end() :]
after = value[m.end():]
value = value[: m.start()] + item + after
if "$" in after:
notdone[name] = value
Expand Down

0 comments on commit 274020a

Please sign in to comment.