From 780bf3ebc86274b1ee3a9680b4ec5612f301fc73 Mon Sep 17 00:00:00 2001 From: Roumen Petrov Date: Sat, 9 Feb 2013 17:07:37 +0200 Subject: [PATCH] MINGW-issue12641: customize mingw&cygwin compilers --- Lib/distutils/cygwinccompiler.py | 14 -------------- Lib/distutils/sysconfig.py | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py index 6919965..6797089 100644 --- a/Lib/distutils/cygwinccompiler.py +++ b/Lib/distutils/cygwinccompiler.py @@ -60,14 +60,6 @@ class CygwinCCompiler(UnixCCompiler): self.linker_dll = "gcc" - # Hard-code GCC because that's what this is all about. - # XXX optimization, warnings etc. should be customizable. - self.set_executables(compiler='gcc -mcygwin -O -Wall', - compiler_so='gcc -mcygwin -mdll -O -Wall', - compiler_cxx='g++ -mcygwin -O -Wall', - linker_exe='gcc -mcygwin', - linker_so='gcc -mcygwin -shared') - # cygwin provides its own C-runtime self.dll_libraries = [] @@ -182,12 +174,6 @@ class Mingw32CCompiler(CygwinCCompiler): CygwinCCompiler.__init__ (self, verbose, dry_run, force) - 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='gcc -mno-cygwin -shared') - # Include the appropriate MSVC runtime library if Python was built # with MSVC 7.0 or later. self.dll_libraries = get_msvcr() diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py index 71492f3..8b79381 100644 --- a/Lib/distutils/sysconfig.py +++ b/Lib/distutils/sysconfig.py @@ -168,7 +168,23 @@ def customize_compiler(compiler): Mainly needed on Unix, so we can plug in the information that varies across Unices and is stored in Python's Makefile. """ - if compiler.compiler_type == "unix": + if compiler.compiler_type in ["cygwin", "mingw32"]: + # Note that cygwin use posix build and 'unix' compiler. + # If build is not based on posix then we must predefine + # some environment variables corresponding to posix + # build rules and defaults. + if not 'GCC' in sys.version: + global _config_vars + _config_vars['CC'] = "gcc" + _config_vars['CXX'] = "g++" + _config_vars['OPT'] = "-fwrapv -O3 -Wall -Wstrict-prototypes" + _config_vars['CFLAGS'] = "" + _config_vars['CCSHARED'] = "" + _config_vars['LDSHARED'] = "gcc -shared -Wl,--enable-auto-image-base" + _config_vars['AR'] = "ar" + _config_vars['ARFLAGS'] = "rc" + + if compiler.compiler_type in ["unix", "cygwin", "mingw32"]: if sys.platform == "darwin": # Perform first-time customization of compiler-related # config vars on OS X now that we know we need a compiler. -- 1.7.12.1