1--- a/Lib/distutils/cygwinccompiler.py
2+++ b/Lib/distutils/cygwinccompiler.py
3@@ -117,8 +117,10 @@
4 # dllwrap 2.10.90 is buggy
5 if self.ld_version >= "2.10.90":
6 self.linker_dll = "gcc"
7+ self.linker_dll_cxx = "g++"
8 else:
9 self.linker_dll = "dllwrap"
10+ self.linker_dll_cxx = "dllwrap"
11
12 # ld_version >= "2.13" support -shared so use it instead of
13 # -mdll -static
14@@ -132,9 +134,13 @@
15 self.set_executables(compiler='gcc -mcygwin -O -Wall',
16 compiler_so='gcc -mcygwin -mdll -O -Wall',
17 compiler_cxx='g++ -mcygwin -O -Wall',
18+ compiler_so_cxx='g++ -mcygwin -mdll -O -Wall',
19 linker_exe='gcc -mcygwin',
20 linker_so=('%s -mcygwin %s' %
21- (self.linker_dll, shared_option)))
22+ (self.linker_dll, shared_option)),
23+ linker_exe_cxx='g++ -mcygwin',
24+ linker_so_cxx=('%s -mcygwin %s' %
25+ (self.linker_dll_cxx, shared_option)))
26
27 # cygwin and mingw32 need different sets of libraries
28 if self.gcc_version == "2.91.57":
29@@ -160,8 +166,12 @@
30 raise CompileError, msg
31 else: # for other files use the C-compiler
32 try:
33- self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
34- extra_postargs)
35+ if self.detect_language(src) == 'c++':
36+ self.spawn(self.compiler_so_cxx + cc_args + [src, '-o', obj] +
37+ extra_postargs)
38+ else:
39+ self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
40+ extra_postargs)
41 except DistutilsExecError, msg:
42 raise CompileError, msg
43
44@@ -327,9 +337,14 @@
45 self.set_executables(compiler='gcc%s -O -Wall' % no_cygwin,
46 compiler_so='gcc%s -mdll -O -Wall' % no_cygwin,
47 compiler_cxx='g++%s -O -Wall' % no_cygwin,
48+ compiler_so_cxx='g++%s -mdll -O -Wall' % no_cygwin,
49 linker_exe='gcc%s' % no_cygwin,
50 linker_so='%s%s %s %s'
51 % (self.linker_dll, no_cygwin,
52+ shared_option, entry_point),
53+ linker_exe_cxx='g++%s' % no_cygwin,
54+ linker_so_cxx='%s%s %s %s'
55+ % (self.linker_dll_cxx, no_cygwin,
56 shared_option, entry_point))
57 # Maybe we should also append -mthreads, but then the finished
58 # dlls need another dll (mingwm10.dll see Mingw32 docs)
59--- a/Lib/distutils/emxccompiler.py
60+++ b/Lib/distutils/emxccompiler.py
61@@ -65,8 +65,12 @@
62 # XXX optimization, warnings etc. should be customizable.
63 self.set_executables(compiler='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
64 compiler_so='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
65+ compiler_cxx='g++ -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
66+ compiler_so_cxx='g++ -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
67 linker_exe='gcc -Zomf -Zmt -Zcrtdll',
68- linker_so='gcc -Zomf -Zmt -Zcrtdll -Zdll')
69+ linker_so='gcc -Zomf -Zmt -Zcrtdll -Zdll',
70+ linker_exe_cxx='g++ -Zomf -Zmt -Zcrtdll',
71+ linker_so_cxx='g++ -Zomf -Zmt -Zcrtdll -Zdll')
72
73 # want the gcc library statically linked (so that we don't have
74 # to distribute a version dependent on the compiler we have)
75@@ -83,8 +87,12 @@
76 raise CompileError, msg
77 else: # for other files use the C-compiler
78 try:
79- self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
80- extra_postargs)
81+ if self.detect_language(src) == 'c++':
82+ self.spawn(self.compiler_so_cxx + cc_args + [src, '-o', obj] +
83+ extra_postargs)
84+ else:
85+ self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
86+ extra_postargs)
87 except DistutilsExecError, msg:
88 raise CompileError, msg
89
90--- a/Lib/distutils/sysconfig.py
91+++ b/Lib/distutils/sysconfig.py
92@@ -170,10 +170,12 @@
93 _osx_support.customize_compiler(_config_vars)
94 _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
95
96- (cc, cxx, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \
97- get_config_vars('CC', 'CXX', 'CFLAGS',
98- 'CCSHARED', 'LDSHARED', 'SO', 'AR',
99- 'ARFLAGS')
100+ (cc, cxx, ccshared, ldshared, ldcxxshared, so_ext, ar, ar_flags) = \
101+ get_config_vars('CC', 'CXX', 'CCSHARED', 'LDSHARED', 'LDCXXSHARED',
102+ 'SO', 'AR', 'ARFLAGS')
103+
104+ cflags = ''
105+ cxxflags = ''
106
107 if 'CC' in os.environ:
108 newcc = os.environ['CC']
109@@ -188,19 +190,27 @@
110 cxx = os.environ['CXX']
111 if 'LDSHARED' in os.environ:
112 ldshared = os.environ['LDSHARED']
113+ if 'LDCXXSHARED' in os.environ:
114+ ldcxxshared = os.environ['LDCXXSHARED']
115 if 'CPP' in os.environ:
116 cpp = os.environ['CPP']
117 else:
118 cpp = cc + " -E" # not always
119 if 'LDFLAGS' in os.environ:
120 ldshared = ldshared + ' ' + os.environ['LDFLAGS']
121+ ldcxxshared = ldcxxshared + ' ' + os.environ['LDFLAGS']
122 if 'CFLAGS' in os.environ:
123 cflags = cflags + ' ' + os.environ['CFLAGS']
124 ldshared = ldshared + ' ' + os.environ['CFLAGS']
125+ if 'CXXFLAGS' in os.environ:
126+ cxxflags = os.environ['CXXFLAGS']
127+ ldcxxshared = ldcxxshared + ' ' + os.environ['CXXFLAGS']
128 if 'CPPFLAGS' in os.environ:
129 cpp = cpp + ' ' + os.environ['CPPFLAGS']
130 cflags = cflags + ' ' + os.environ['CPPFLAGS']
131+ cxxflags = cxxflags + ' ' + os.environ['CPPFLAGS']
132 ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
133+ ldcxxshared = ldcxxshared + ' ' + os.environ['CPPFLAGS']
134 if 'AR' in os.environ:
135 ar = os.environ['AR']
136 if 'ARFLAGS' in os.environ:
137@@ -209,13 +219,17 @@
138 archiver = ar + ' ' + ar_flags
139
140 cc_cmd = cc + ' ' + cflags
141+ cxx_cmd = cxx + ' ' + cxxflags
142 compiler.set_executables(
143 preprocessor=cpp,
144 compiler=cc_cmd,
145 compiler_so=cc_cmd + ' ' + ccshared,
146- compiler_cxx=cxx,
147+ compiler_cxx=cxx_cmd,
148+ compiler_so_cxx=cxx_cmd + ' ' + ccshared,
149 linker_so=ldshared,
150 linker_exe=cc,
151+ linker_so_cxx=ldcxxshared,
152+ linker_exe_cxx=cxx,
153 archiver=archiver)
154
155 compiler.shared_lib_extension = so_ext
156--- a/Lib/distutils/unixccompiler.py
157+++ b/Lib/distutils/unixccompiler.py
158@@ -55,14 +55,17 @@
159 # are pretty generic; they will probably have to be set by an outsider
160 # (eg. using information discovered by the sysconfig about building
161 # Python extensions).
162- executables = {'preprocessor' : None,
163- 'compiler' : ["cc"],
164- 'compiler_so' : ["cc"],
165- 'compiler_cxx' : ["cc"],
166- 'linker_so' : ["cc", "-shared"],
167- 'linker_exe' : ["cc"],
168- 'archiver' : ["ar", "-cr"],
169- 'ranlib' : None,
170+ executables = {'preprocessor' : None,
171+ 'compiler' : ["cc"],
172+ 'compiler_so' : ["cc"],
173+ 'compiler_cxx' : ["c++"],
174+ 'compiler_so_cxx' : ["c++"],
175+ 'linker_so' : ["cc", "-shared"],
176+ 'linker_exe' : ["cc"],
177+ 'linker_so_cxx' : ["c++", "-shared"],
178+ 'linker_exe_cxx' : ["c++"],
179+ 'archiver' : ["ar", "-cr"],
180+ 'ranlib' : None,
181 }
182
183 if sys.platform[:6] == "darwin":
184@@ -112,12 +115,19 @@
185
186 def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
187 compiler_so = self.compiler_so
188+ compiler_so_cxx = self.compiler_so_cxx
189 if sys.platform == 'darwin':
190 compiler_so = _osx_support.compiler_fixup(compiler_so,
191 cc_args + extra_postargs)
192+ compiler_so_cxx = _osx_support.compiler_fixup(compiler_so_cxx,
193+ cc_args + extra_postargs)
194 try:
195- self.spawn(compiler_so + cc_args + [src, '-o', obj] +
196- extra_postargs)
197+ if self.detect_language(src) == 'c++':
198+ self.spawn(compiler_so_cxx + cc_args + [src, '-o', obj] +
199+ extra_postargs)
200+ else:
201+ self.spawn(compiler_so + cc_args + [src, '-o', obj] +
202+ extra_postargs)
203 except DistutilsExecError, msg:
204 raise CompileError, msg
205
206@@ -174,23 +184,16 @@
207 ld_args.extend(extra_postargs)
208 self.mkpath(os.path.dirname(output_filename))
209 try:
210- if target_desc == CCompiler.EXECUTABLE:
211- linker = self.linker_exe[:]
212+ if target_lang == "c++":
213+ if target_desc == CCompiler.EXECUTABLE:
214+ linker = self.linker_exe_cxx[:]
215+ else:
216+ linker = self.linker_so_cxx[:]
217 else:
218- linker = self.linker_so[:]
219- if target_lang == "c++" and self.compiler_cxx:
220- # skip over environment variable settings if /usr/bin/env
221- # is used to set up the linker's environment.
222- # This is needed on OSX. Note: this assumes that the
223- # normal and C++ compiler have the same environment
224- # settings.
225- i = 0
226- if os.path.basename(linker[0]) == "env":
227- i = 1
228- while '=' in linker[i]:
229- i = i + 1
230-
231- linker[i] = self.compiler_cxx[i]
232+ if target_desc == CCompiler.EXECUTABLE:
233+ linker = self.linker_exe[:]
234+ else:
235+ linker = self.linker_so[:]
236
237 if sys.platform == 'darwin':
238 linker = _osx_support.compiler_fixup(linker, ld_args)
239--- a/Lib/_osx_support.py
240+++ b/Lib/_osx_support.py
241@@ -14,13 +14,13 @@
242 # configuration variables that may contain universal build flags,
243 # like "-arch" or "-isdkroot", that may need customization for
244 # the user environment
245-_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS', 'BASECFLAGS',
246- 'BLDSHARED', 'LDSHARED', 'CC', 'CXX',
247- 'PY_CFLAGS', 'PY_LDFLAGS', 'PY_CPPFLAGS',
248- 'PY_CORE_CFLAGS')
249+_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'CXXFLAGS', 'LDFLAGS', 'CPPFLAGS',
250+ 'BASECFLAGS', 'BLDSHARED', 'LDSHARED', 'LDCXXSHARED',
251+ 'CC', 'CXX', 'PY_CFLAGS', 'PY_LDFLAGS',
252+ 'PY_CPPFLAGS', 'PY_CORE_CFLAGS')
253
254 # configuration variables that may contain compiler calls
255-_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'CC', 'CXX')
256+_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'LDCXXSHARED', 'CC', 'CXX')
257
258 # prefix added to original configuration variable names
259 _INITPRE = '_OSX_SUPPORT_INITIAL_'