Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3c678c3

Browse files
committed
Issue #12641: Avoid passing "-mno-cygwin" to the mingw32 compiler, except when necessary.
Patch by Oscar Benjamin.
1 parent 1a67bee commit 3c678c3

3 files changed

Lines changed: 22 additions & 8 deletions

File tree

Lib/distutils/cygwinccompiler.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
import os
4949
import sys
5050
import copy
51-
from subprocess import Popen, PIPE
51+
from subprocess import Popen, PIPE, check_output
5252
import re
5353

5454
from distutils.ccompiler import gen_preprocess_options, gen_lib_options
@@ -294,13 +294,18 @@ def __init__(self, verbose=0, dry_run=0, force=0):
294294
else:
295295
entry_point = ''
296296

297-
self.set_executables(compiler='gcc -mno-cygwin -O -Wall',
298-
compiler_so='gcc -mno-cygwin -mdll -O -Wall',
299-
compiler_cxx='g++ -mno-cygwin -O -Wall',
300-
linker_exe='gcc -mno-cygwin',
301-
linker_so='%s -mno-cygwin %s %s'
302-
% (self.linker_dll, shared_option,
303-
entry_point))
297+
if self.gcc_version < '4' or is_cygwingcc():
298+
no_cygwin = ' -mno-cygwin'
299+
else:
300+
no_cygwin = ''
301+
302+
self.set_executables(compiler='gcc%s -O -Wall' % no_cygwin,
303+
compiler_so='gcc%s -mdll -O -Wall' % no_cygwin,
304+
compiler_cxx='g++%s -O -Wall' % no_cygwin,
305+
linker_exe='gcc%s' % no_cygwin,
306+
linker_so='%s%s %s %s'
307+
% (self.linker_dll, no_cygwin,
308+
shared_option, entry_point))
304309
# Maybe we should also append -mthreads, but then the finished
305310
# dlls need another dll (mingwm10.dll see Mingw32 docs)
306311
# (-mthreads: Support thread-safe exception handling on `Mingw32')
@@ -393,3 +398,8 @@ def get_versions():
393398
"""
394399
commands = ['gcc -dumpversion', 'ld -v', 'dllwrap --version']
395400
return tuple([_find_exe_version(cmd) for cmd in commands])
401+
402+
def is_cygwingcc():
403+
'''Try to determine if the gcc that would be used is from cygwin.'''
404+
out_string = check_output(['gcc', '-dumpmachine'])
405+
return out_string.strip().endswith(b'cygwin')

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ Thomas Bellman
101101
Alexander “Саша” Belopolsky
102102
Eli Bendersky
103103
David Benjamin
104+
Oscar Benjamin
104105
Andrew Bennetts
105106
Andy Bensky
106107
Bennett Benson

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ Core and Builtins
7171
Library
7272
-------
7373

74+
- Issue #12641: Avoid passing "-mno-cygwin" to the mingw32 compiler, except
75+
when necessary. Patch by Oscar Benjamin.
76+
7477
- Properly initialize all fields of a SSL object after allocation.
7578

7679
- Issue #4366: Fix building extensions on all platforms when --enable-shared

0 commit comments

Comments
 (0)