[Python-checkins] cpython (merge 3.3 -> default): Issue #12641: Avoid passing "-mno-cygwin" to the mingw32 compiler, except when

antoine.pitrou python-checkins at python.org
Mon Sep 30 22:29:59 CEST 2013


http://hg.python.org/cpython/rev/8e180b2067e4
changeset:   85894:8e180b2067e4
parent:      85888:d329bc30f2d6
parent:      85893:6b89176f1be5
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Mon Sep 30 22:29:48 2013 +0200
summary:
  Issue #12641: Avoid passing "-mno-cygwin" to the mingw32 compiler, except when necessary.
Patch by Oscar Benjamin.

files:
  Lib/distutils/cygwinccompiler.py |  24 ++++++++++++++-----
  Misc/ACKS                        |   1 +
  Misc/NEWS                        |   3 ++
  3 files changed, 21 insertions(+), 7 deletions(-)


diff --git a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py
--- a/Lib/distutils/cygwinccompiler.py
+++ b/Lib/distutils/cygwinccompiler.py
@@ -48,13 +48,14 @@
 import os
 import sys
 import copy
-from subprocess import Popen, PIPE
+from subprocess import Popen, PIPE, check_output
 import re
 
 from distutils.ccompiler import gen_preprocess_options, gen_lib_options
 from distutils.unixccompiler import UnixCCompiler
 from distutils.file_util import write_file
-from distutils.errors import DistutilsExecError, CompileError, UnknownFileError
+from distutils.errors import (DistutilsExecError, CCompilerError,
+        CompileError, UnknownFileError)
 from distutils import log
 from distutils.version import LooseVersion
 from distutils.spawn import find_executable
@@ -294,11 +295,15 @@
         else:
             entry_point = ''
 
-        self.set_executables(compiler='gcc -mno-cygwin -O -Wall',
-                             compiler_so='gcc -mno-cygwin -mdll -O -Wall',
-                             compiler_cxx='g++ -mno-cygwin -O -Wall',
-                             linker_exe='gcc -mno-cygwin',
-                             linker_so='%s -mno-cygwin %s %s'
+        if is_cygwingcc():
+            raise CCompilerError(
+                'Cygwin gcc cannot be used with --compiler=mingw32')
+
+        self.set_executables(compiler='gcc -O -Wall',
+                             compiler_so='gcc -mdll -O -Wall',
+                             compiler_cxx='g++ -O -Wall',
+                             linker_exe='gcc',
+                             linker_so='%s %s %s'
                                         % (self.linker_dll, shared_option,
                                            entry_point))
         # Maybe we should also append -mthreads, but then the finished
@@ -393,3 +398,8 @@
     """
     commands = ['gcc -dumpversion', 'ld -v', 'dllwrap --version']
     return tuple([_find_exe_version(cmd) for cmd in commands])
+
+def is_cygwingcc():
+    '''Try to determine if the gcc that would be used is from cygwin.'''
+    out_string = check_output(['gcc', '-dumpmachine'])
+    return out_string.strip().endswith(b'cygwin')
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -102,6 +102,7 @@
 Alexander “Саша” Belopolsky
 Eli Bendersky
 David Benjamin
+Oscar Benjamin
 Andrew Bennetts
 Andy Bensky
 Bennett Benson
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -13,6 +13,9 @@
 Library
 -------
 
+- Issue #12641: Avoid passing "-mno-cygwin" to the mingw32 compiler, except
+  when necessary.  Patch by Oscar Benjamin.
+
 - Issue #5845: In site.py, only load readline history from ~/.python_history
   if no history has been read already.  This avoids double writes to the
   history file at shutdown.

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list