summaryrefslogtreecommitdiff
path: root/Lib/distutils
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2013-09-30 22:29:48 +0200
committerAntoine Pitrou <solipsis@pitrou.net>2013-09-30 22:29:48 +0200
commitdea46b2522c26d0732a6357904a5b0530ebd076f (patch)
treed9dc20a28aaf788823d0ceb7fa3e53dbfa1ba8a5 /Lib/distutils
parent37009692bb86cb5014a821cab29292f5d95a1a77 (diff)
parent4d6845a0c89dca30d18469da061b8eba4ec691c1 (diff)
downloadcpython-dea46b2522c26d0732a6357904a5b0530ebd076f.tar.gz
Issue #12641: Avoid passing "-mno-cygwin" to the mingw32 compiler, except when necessary.
Patch by Oscar Benjamin.
Diffstat (limited to 'Lib/distutils')
-rw-r--r--Lib/distutils/cygwinccompiler.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py
index 0c23ab1b7f..d28b1b368a 100644
--- a/Lib/distutils/cygwinccompiler.py
+++ b/Lib/distutils/cygwinccompiler.py
@@ -48,13 +48,14 @@ 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
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 @@ 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'
+ 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 @@ 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')