]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #12641: Avoid passing "-mno-cygwin" to the mingw32 compiler, except when necessary.
authorAntoine Pitrou <solipsis@pitrou.net>
Mon, 30 Sep 2013 20:28:10 +0000 (22:28 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Mon, 30 Sep 2013 20:28:10 +0000 (22:28 +0200)
Patch by Oscar Benjamin.

Lib/distutils/cygwinccompiler.py
Misc/ACKS
Misc/NEWS

index 0bdd539c37eb1941ec8b6f77f945438ce0a3faba..e0074a18f300231bacbe9ac0019d5b3443858aa0 100644 (file)
@@ -48,7 +48,7 @@ cygwin in no-cygwin mode).
 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
@@ -294,13 +294,18 @@ class Mingw32CCompiler(CygwinCCompiler):
         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'
-                                        % (self.linker_dll, shared_option,
-                                           entry_point))
+        if self.gcc_version < '4' or is_cygwingcc():
+            no_cygwin = ' -mno-cygwin'
+        else:
+            no_cygwin = ''
+
+        self.set_executables(compiler='gcc%s -O -Wall' % no_cygwin,
+                             compiler_so='gcc%s -mdll -O -Wall' % no_cygwin,
+                             compiler_cxx='g++%s -O -Wall' % no_cygwin,
+                             linker_exe='gcc%s' % no_cygwin,
+                             linker_so='%s%s %s %s'
+                                    % (self.linker_dll, no_cygwin,
+                                       shared_option, entry_point))
         # Maybe we should also append -mthreads, but then the finished
         # dlls need another dll (mingwm10.dll see Mingw32 docs)
         # (-mthreads: Support thread-safe exception handling on `Mingw32')
@@ -393,3 +398,8 @@ def get_versions():
     """
     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')
index b5ebf0698a2938b880c4d65db52b91513df7a399..63c126c7cc0564ed9a98de5aa656c27a7c4f4de3 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -101,6 +101,7 @@ Thomas Bellman
 Alexander “Саша” Belopolsky
 Eli Bendersky
 David Benjamin
+Oscar Benjamin
 Andrew Bennetts
 Andy Bensky
 Bennett Benson
index 63601d8f11571766d5603da1fd4f762374a96292..c787537857ada29baf04c0fb02eea24af77406d9 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -71,6 +71,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #12641: Avoid passing "-mno-cygwin" to the mingw32 compiler, except
+  when necessary.  Patch by Oscar Benjamin.
+
 - Properly initialize all fields of a SSL object after allocation.
 
 - Issue #4366: Fix building extensions on all platforms when --enable-shared