|
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 |
@@ -294,13 +294,18 @@ def __init__(self, verbose=0, dry_run=0, force=0): |
294 | 294 | else: |
295 | 295 | entry_point = '' |
296 | 296 |
|
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)) |
304 | 309 | # Maybe we should also append -mthreads, but then the finished |
305 | 310 | # dlls need another dll (mingwm10.dll see Mingw32 docs) |
306 | 311 | # (-mthreads: Support thread-safe exception handling on `Mingw32') |
@@ -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