at 18.09-beta 12 kB view raw
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, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \ 97- get_config_vars('CC', 'CXX', 'OPT', '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 = opt + ' ' + os.environ['CFLAGS'] 124+ cflags = os.environ['CFLAGS'] 125 ldshared = ldshared + ' ' + os.environ['CFLAGS'] 126+ if 'CXXFLAGS' in os.environ: 127+ cxxflags = os.environ['CXXFLAGS'] 128+ ldcxxshared = ldcxxshared + ' ' + os.environ['CXXFLAGS'] 129 if 'CPPFLAGS' in os.environ: 130 cpp = cpp + ' ' + os.environ['CPPFLAGS'] 131 cflags = cflags + ' ' + os.environ['CPPFLAGS'] 132+ cxxflags = cxxflags + ' ' + os.environ['CPPFLAGS'] 133 ldshared = ldshared + ' ' + os.environ['CPPFLAGS'] 134+ ldcxxshared = ldcxxshared + ' ' + os.environ['CPPFLAGS'] 135 if 'AR' in os.environ: 136 ar = os.environ['AR'] 137 if 'ARFLAGS' in os.environ: 138@@ -209,13 +219,17 @@ 139 archiver = ar + ' ' + ar_flags 140 141 cc_cmd = cc + ' ' + cflags 142+ cxx_cmd = cxx + ' ' + cxxflags 143 compiler.set_executables( 144 preprocessor=cpp, 145 compiler=cc_cmd, 146 compiler_so=cc_cmd + ' ' + ccshared, 147- compiler_cxx=cxx, 148+ compiler_cxx=cxx_cmd, 149+ compiler_so_cxx=cxx_cmd + ' ' + ccshared, 150 linker_so=ldshared, 151 linker_exe=cc, 152+ linker_so_cxx=ldcxxshared, 153+ linker_exe_cxx=cxx, 154 archiver=archiver) 155 156 compiler.shared_lib_extension = so_ext 157--- a/Lib/distutils/unixccompiler.py 158+++ b/Lib/distutils/unixccompiler.py 159@@ -55,14 +55,17 @@ 160 # are pretty generic; they will probably have to be set by an outsider 161 # (eg. using information discovered by the sysconfig about building 162 # Python extensions). 163- executables = {'preprocessor' : None, 164- 'compiler' : ["cc"], 165- 'compiler_so' : ["cc"], 166- 'compiler_cxx' : ["cc"], 167- 'linker_so' : ["cc", "-shared"], 168- 'linker_exe' : ["cc"], 169- 'archiver' : ["ar", "-cr"], 170- 'ranlib' : None, 171+ executables = {'preprocessor' : None, 172+ 'compiler' : ["cc"], 173+ 'compiler_so' : ["cc"], 174+ 'compiler_cxx' : ["c++"], 175+ 'compiler_so_cxx' : ["c++"], 176+ 'linker_so' : ["cc", "-shared"], 177+ 'linker_exe' : ["cc"], 178+ 'linker_so_cxx' : ["c++", "-shared"], 179+ 'linker_exe_cxx' : ["c++"], 180+ 'archiver' : ["ar", "-cr"], 181+ 'ranlib' : None, 182 } 183 184 if sys.platform[:6] == "darwin": 185@@ -112,12 +115,19 @@ 186 187 def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): 188 compiler_so = self.compiler_so 189+ compiler_so_cxx = self.compiler_so_cxx 190 if sys.platform == 'darwin': 191 compiler_so = _osx_support.compiler_fixup(compiler_so, 192 cc_args + extra_postargs) 193+ compiler_so_cxx = _osx_support.compiler_fixup(compiler_so_cxx, 194+ cc_args + extra_postargs) 195 try: 196- self.spawn(compiler_so + cc_args + [src, '-o', obj] + 197- extra_postargs) 198+ if self.detect_language(src) == 'c++': 199+ self.spawn(compiler_so_cxx + cc_args + [src, '-o', obj] + 200+ extra_postargs) 201+ else: 202+ self.spawn(compiler_so + cc_args + [src, '-o', obj] + 203+ extra_postargs) 204 except DistutilsExecError, msg: 205 raise CompileError, msg 206 207@@ -174,23 +184,16 @@ 208 ld_args.extend(extra_postargs) 209 self.mkpath(os.path.dirname(output_filename)) 210 try: 211- if target_desc == CCompiler.EXECUTABLE: 212- linker = self.linker_exe[:] 213+ if target_lang == "c++": 214+ if target_desc == CCompiler.EXECUTABLE: 215+ linker = self.linker_exe_cxx[:] 216+ else: 217+ linker = self.linker_so_cxx[:] 218 else: 219- linker = self.linker_so[:] 220- if target_lang == "c++" and self.compiler_cxx: 221- # skip over environment variable settings if /usr/bin/env 222- # is used to set up the linker's environment. 223- # This is needed on OSX. Note: this assumes that the 224- # normal and C++ compiler have the same environment 225- # settings. 226- i = 0 227- if os.path.basename(linker[0]) == "env": 228- i = 1 229- while '=' in linker[i]: 230- i = i + 1 231- 232- linker[i] = self.compiler_cxx[i] 233+ if target_desc == CCompiler.EXECUTABLE: 234+ linker = self.linker_exe[:] 235+ else: 236+ linker = self.linker_so[:] 237 238 if sys.platform == 'darwin': 239 linker = _osx_support.compiler_fixup(linker, ld_args) 240--- a/Lib/_osx_support.py 241+++ b/Lib/_osx_support.py 242@@ -14,13 +14,13 @@ 243 # configuration variables that may contain universal build flags, 244 # like "-arch" or "-isdkroot", that may need customization for 245 # the user environment 246-_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS', 'BASECFLAGS', 247- 'BLDSHARED', 'LDSHARED', 'CC', 'CXX', 248- 'PY_CFLAGS', 'PY_LDFLAGS', 'PY_CPPFLAGS', 249- 'PY_CORE_CFLAGS') 250+_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'CXXFLAGS', 'LDFLAGS', 'CPPFLAGS', 251+ 'BASECFLAGS', 'BLDSHARED', 'LDSHARED', 'LDCXXSHARED', 252+ 'CC', 'CXX', 'PY_CFLAGS', 'PY_LDFLAGS', 253+ 'PY_CPPFLAGS', 'PY_CORE_CFLAGS') 254 255 # configuration variables that may contain compiler calls 256-_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'CC', 'CXX') 257+_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'LDCXXSHARED', 'CC', 'CXX') 258 259 # prefix added to original configuration variable names 260 _INITPRE = '_OSX_SUPPORT_INITIAL_'