Merge pull request #307098 from r-ryantm/auto-update/cilium-cli
[NixPkgs.git] / pkgs / development / python-modules / setuptools / setuptools-distutils-C++.patch
blob399e1682357de04459e7b09f604e8ef6232de3ec
1 diff --git a/setuptools/_distutils/cygwinccompiler.py b/setuptools/_distutils/cygwinccompiler.py
2 index 47efa377..5cdbbe10 100644
3 --- a/setuptools/_distutils/cygwinccompiler.py
4 +++ b/setuptools/_distutils/cygwinccompiler.py
5 @@ -101,14 +101,19 @@ class CygwinCCompiler(UnixCCompiler):
6 self.cxx = os.environ.get('CXX', 'g++')
8 self.linker_dll = self.cc
9 + self.linker_dll_cxx = self.cxx
10 shared_option = "-shared"
12 self.set_executables(
13 compiler='%s -mcygwin -O -Wall' % self.cc,
14 compiler_so='%s -mcygwin -mdll -O -Wall' % self.cc,
15 compiler_cxx='%s -mcygwin -O -Wall' % self.cxx,
16 + compiler_so_cxx='%s -mcygwin -mdll -O -Wall' % self.cxx,
17 linker_exe='%s -mcygwin' % self.cc,
18 linker_so=('{} -mcygwin {}'.format(self.linker_dll, shared_option)),
19 + linker_exe_cxx='%s -mcygwin' % self.cxx,
20 + linker_so_cxx=('%s -mcygwin %s' %
21 + (self.linker_dll_cxx, shared_option)),
24 # Include the appropriate MSVC runtime library if Python was built
25 @@ -140,9 +145,12 @@ class CygwinCCompiler(UnixCCompiler):
26 raise CompileError(msg)
27 else: # for other files use the C-compiler
28 try:
29 - self.spawn(
30 - self.compiler_so + cc_args + [src, '-o', obj] + extra_postargs
31 - )
32 + if self.detect_language(src) == 'c++':
33 + self.spawn(self.compiler_so_cxx + cc_args + [src, '-o', obj] +
34 + extra_postargs)
35 + else:
36 + self.spawn(
37 + self.compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
38 except DistutilsExecError as msg:
39 raise CompileError(msg)
41 @@ -278,9 +286,12 @@ class Mingw32CCompiler(CygwinCCompiler):
42 self.set_executables(
43 compiler='%s -O -Wall' % self.cc,
44 compiler_so='%s -mdll -O -Wall' % self.cc,
45 + compiler_so_cxx='%s -mdll -O -Wall' % self.cxx,
46 compiler_cxx='%s -O -Wall' % self.cxx,
47 linker_exe='%s' % self.cc,
48 linker_so='{} {}'.format(self.linker_dll, shared_option),
49 + linker_exe_cxx='%s' % self.cxx,
50 + linker_so_cxx='%s %s' % (self.linker_dll_cxx, shared_option)
53 def runtime_library_dir_option(self, dir):
54 diff --git a/setuptools/_distutils/sysconfig.py b/setuptools/_distutils/sysconfig.py
55 index a40a7231..e5aad4f4 100644
56 --- a/setuptools/_distutils/sysconfig.py
57 +++ b/setuptools/_distutils/sysconfig.py
58 @@ -297,6 +297,7 @@ def customize_compiler(compiler): # noqa: C901
59 cflags,
60 ccshared,
61 ldshared,
62 + ldcxxshared,
63 shlib_suffix,
64 ar,
65 ar_flags,
66 @@ -306,11 +307,14 @@ def customize_compiler(compiler): # noqa: C901
67 'CFLAGS',
68 'CCSHARED',
69 'LDSHARED',
70 + 'LDCXXSHARED',
71 'SHLIB_SUFFIX',
72 'AR',
73 'ARFLAGS',
76 + cxxflags = cflags
78 if 'CC' in os.environ:
79 newcc = os.environ['CC']
80 if 'LDSHARED' not in os.environ and ldshared.startswith(cc):
81 @@ -322,19 +326,27 @@ def customize_compiler(compiler): # noqa: C901
82 cxx = os.environ['CXX']
83 if 'LDSHARED' in os.environ:
84 ldshared = os.environ['LDSHARED']
85 + if 'LDCXXSHARED' in os.environ:
86 + ldcxxshared = os.environ['LDCXXSHARED']
87 if 'CPP' in os.environ:
88 cpp = os.environ['CPP']
89 else:
90 cpp = cc + " -E" # not always
91 if 'LDFLAGS' in os.environ:
92 ldshared = ldshared + ' ' + os.environ['LDFLAGS']
93 + ldcxxshared = ldcxxshared + ' ' + os.environ['LDFLAGS']
94 if 'CFLAGS' in os.environ:
95 - cflags = cflags + ' ' + os.environ['CFLAGS']
96 + cflags = os.environ['CFLAGS']
97 ldshared = ldshared + ' ' + os.environ['CFLAGS']
98 + if 'CXXFLAGS' in os.environ:
99 + cxxflags = os.environ['CXXFLAGS']
100 + ldcxxshared = ldcxxshared + ' ' + os.environ['CXXFLAGS']
101 if 'CPPFLAGS' in os.environ:
102 cpp = cpp + ' ' + os.environ['CPPFLAGS']
103 cflags = cflags + ' ' + os.environ['CPPFLAGS']
104 + cxxflags = cxxflags + ' ' + os.environ['CPPFLAGS']
105 ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
106 + ldcxxshared = ldcxxshared + ' ' + os.environ['CPPFLAGS']
107 if 'AR' in os.environ:
108 ar = os.environ['AR']
109 if 'ARFLAGS' in os.environ:
110 @@ -343,13 +355,17 @@ def customize_compiler(compiler): # noqa: C901
111 archiver = ar + ' ' + ar_flags
113 cc_cmd = cc + ' ' + cflags
114 + cxx_cmd = cxx + ' ' + cxxflags
115 compiler.set_executables(
116 preprocessor=cpp,
117 compiler=cc_cmd,
118 compiler_so=cc_cmd + ' ' + ccshared,
119 - compiler_cxx=cxx,
120 + compiler_cxx=cxx_cmd,
121 + compiler_so_cxx=cxx_cmd + ' ' + ccshared,
122 linker_so=ldshared,
123 + linker_so_cxx=ldcxxshared,
124 linker_exe=cc,
125 + linker_exe_cxx=cxx,
126 archiver=archiver,
129 diff --git a/setuptools/_distutils/unixccompiler.py b/setuptools/_distutils/unixccompiler.py
130 index 6ca2332a..5ac64128 100644
131 --- a/setuptools/_distutils/unixccompiler.py
132 +++ b/setuptools/_distutils/unixccompiler.py
133 @@ -115,9 +115,12 @@ class UnixCCompiler(CCompiler):
134 'preprocessor': None,
135 'compiler': ["cc"],
136 'compiler_so': ["cc"],
137 - 'compiler_cxx': ["cc"],
138 + 'compiler_cxx': ["c++"],
139 + 'compiler_so_cxx': ["c++"],
140 'linker_so': ["cc", "-shared"],
141 + 'linker_so_cxx': ["c++", "-shared"],
142 'linker_exe': ["cc"],
143 + 'linker_exe_cxx': ["c++", "-shared"],
144 'archiver': ["ar", "-cr"],
145 'ranlib': None,
147 @@ -181,8 +184,13 @@ class UnixCCompiler(CCompiler):
149 def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
150 compiler_so = compiler_fixup(self.compiler_so, cc_args + extra_postargs)
151 + compiler_so_cxx = compiler_fixup(self.compiler_so_cxx, cc_args + extra_postargs)
152 try:
153 - self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
154 + if self.detect_language(src) == 'c++':
155 + self.spawn(compiler_so_cxx + cc_args + [ src, '-o', obj] +
156 + extra_postargs)
157 + else:
158 + self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
159 except DistutilsExecError as msg:
160 raise CompileError(msg)
162 @@ -250,7 +258,8 @@ class UnixCCompiler(CCompiler):
163 # building an executable or linker_so (with shared options)
164 # when building a shared library.
165 building_exe = target_desc == CCompiler.EXECUTABLE
166 - linker = (self.linker_exe if building_exe else self.linker_so)[:]
167 + linker = (self.linker_exe if building_exe else (self.linker_so_cxx if
168 + target_lang == "c++" else self.linker_so))[:]
170 if target_lang == "c++" and self.compiler_cxx:
171 env, linker_ne = _split_env(linker)