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

Skip to content

Commit 6a9c0e5

Browse files
committed
Issue #12641: Avoid passing "-mno-cygwin" to the mingw32 compiler, except when necessary.
Patch by Oscar Benjamin.
2 parents c8fb4fc + 3c678c3 commit 6a9c0e5

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

Lib/distutils/cygwinccompiler.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@
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
5555
from distutils.unixccompiler import UnixCCompiler
5656
from distutils.file_util import write_file
57-
from distutils.errors import DistutilsExecError, CompileError, UnknownFileError
57+
from distutils.errors import (DistutilsExecError, CCompilerError,
58+
CompileError, UnknownFileError)
5859
from distutils import log
5960
from distutils.version import LooseVersion
6061
from distutils.spawn import find_executable
@@ -294,11 +295,15 @@ def __init__(self, verbose=0, dry_run=0, force=0):
294295
else:
295296
entry_point = ''
296297

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'
298+
if is_cygwingcc():
299+
raise CCompilerError(
300+
'Cygwin gcc cannot be used with --compiler=mingw32')
301+
302+
self.set_executables(compiler='gcc -O -Wall',
303+
compiler_so='gcc -mdll -O -Wall',
304+
compiler_cxx='g++ -O -Wall',
305+
linker_exe='gcc',
306+
linker_so='%s %s %s'
302307
% (self.linker_dll, shared_option,
303308
entry_point))
304309
# Maybe we should also append -mthreads, but then the finished
@@ -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
@@ -102,6 +102,7 @@ Thomas Bellman
102102
Alexander “Саша” Belopolsky
103103
Eli Bendersky
104104
David Benjamin
105+
Oscar Benjamin
105106
Andrew Bennetts
106107
Andy Bensky
107108
Bennett Benson

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Core and Builtins
1313
Library
1414
-------
1515

16+
- Issue #12641: Avoid passing "-mno-cygwin" to the mingw32 compiler, except
17+
when necessary. Patch by Oscar Benjamin.
18+
1619
- Issue #5845: In site.py, only load readline history from ~/.python_history
1720
if no history has been read already. This avoids double writes to the
1821
history file at shutdown.

0 commit comments

Comments
 (0)