From 85e43f1aa493e5aabbaec60ba5552364178b73be Mon Sep 17 00:00:00 2001 From: Roumen Petrov Date: Sat, 9 Feb 2013 20:05:59 +0200 Subject: [PATCH] MINGW-issue12641: check if cygwin/mingw* compiler support -m{no-}cygwin --- Lib/distutils/sysconfig.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py index 8b79381..e3ceb53 100644 --- a/Lib/distutils/sysconfig.py +++ b/Lib/distutils/sysconfig.py @@ -231,6 +231,27 @@ def customize_compiler(compiler): else: archiver = ar + ' ' + ar_flags + if compiler.compiler_type in ["cygwin", "mingw32"]: + # Check if cygwin/mingw* compiler support -m{no-}cygwin. + # If is supported then force use of option, otherwise + # it is true cross-compiler. + import subprocess + + target_help = subprocess.Popen( + [cc, "--target-help"], + stdout=subprocess.PIPE, stderr=subprocess.STDOUT + ).communicate()[0].decode('latin-1') + + if '-mno-cygwin' in target_help: + if compiler.compiler_type == "mingw32": + cc += " -mno-cygwin" + cxx += " -mno-cygwin" + ldshared += " -mno-cygwin" + else: + cc += " -mcygwin" + cxx += " -mcygwin" + ldshared += " -mcygwin" + cc_cmd = cc + ' ' + cflags compiler.set_executables( preprocessor=cpp, -- 1.7.12.1