|
48 | 48 | import os |
49 | 49 | import sys |
50 | 50 | import copy |
51 | | -from subprocess import Popen, PIPE |
| 51 | +from subprocess import Popen, PIPE, check_output |
52 | 52 | import re |
53 | 53 |
|
54 | 54 | from distutils.ccompiler import gen_preprocess_options, gen_lib_options |
55 | 55 | from distutils.unixccompiler import UnixCCompiler |
56 | 56 | 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) |
58 | 59 | from distutils import log |
59 | 60 | from distutils.version import LooseVersion |
60 | 61 | from distutils.spawn import find_executable |
@@ -294,11 +295,15 @@ def __init__(self, verbose=0, dry_run=0, force=0): |
294 | 295 | else: |
295 | 296 | entry_point = '' |
296 | 297 |
|
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' |
302 | 307 | % (self.linker_dll, shared_option, |
303 | 308 | entry_point)) |
304 | 309 | # Maybe we should also append -mthreads, but then the finished |
@@ -393,3 +398,8 @@ def get_versions(): |
393 | 398 | """ |
394 | 399 | commands = ['gcc -dumpversion', 'ld -v', 'dllwrap --version'] |
395 | 400 | 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') |
0 commit comments