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