Skip to content

Commit aac2cf7

Browse files
Alexpuxnaveen521kk
authored andcommitted
distutils: compiler customize mingw cygwin compilers
Co-authored-by: Naveen M K <[email protected]>
1 parent 7b1cd02 commit aac2cf7

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Lib/distutils/sysconfig.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,23 @@ def customize_compiler(compiler):
196196
Mainly needed on Unix, so we can plug in the information that
197197
varies across Unices and is stored in Python's Makefile.
198198
"""
199-
if compiler.compiler_type == "unix":
199+
global _config_vars
200+
if compiler.compiler_type in ["cygwin", "mingw32"]:
201+
# Note that cygwin use posix build and 'unix' compiler.
202+
# If build is not based on posix then we must predefine
203+
# some environment variables corresponding to posix
204+
# build rules and defaults.
205+
if not 'GCC' in sys.version:
206+
_config_vars['CC'] = "gcc"
207+
_config_vars['CXX'] = "g++"
208+
_config_vars['OPT'] = "-fwrapv -O3 -Wall -Wstrict-prototypes"
209+
_config_vars['CFLAGS'] = ""
210+
_config_vars['CCSHARED'] = ""
211+
_config_vars['LDSHARED'] = "gcc -shared -Wl,--enable-auto-image-base"
212+
_config_vars['AR'] = "ar"
213+
_config_vars['ARFLAGS'] = "rc"
214+
215+
if compiler.compiler_type in ["unix", "cygwin", "mingw32"]:
200216
if sys.platform == "darwin":
201217
# Perform first-time customization of compiler-related
202218
# config vars on OS X now that we know we need a compiler.

0 commit comments

Comments
 (0)