[Python-Dev] Status of C compilers for Python on Windows

Sturla Molden sturla.molden at gmail.com
Fri Oct 10 13:20:54 CEST 2014


Larry Hastings <larry at hastings.org> wrote:

> Just to make something clear that may not be clear to non-Windows
> developers: the C library is implicitly part of the ABI.  

MacOS X also has this issue, but it less known amon Mac developers! There
tends to be multiple versions of the C library, one for each SDK version.
If you link the wrong one when building a Python extension it can crash.
For example if you have Python built with the 10.6 SDK (e.g. Enthought) but
has XCode with the 10.9 SDK as default, you need to build with the flag
-mmacosx-version-min=10.6, and for C++ also -stdlib=libstdc++. Not doing so
will cause all sorts of mysterious errors.


Two other ABI problems on Windows is the stack alignment and the MinGW
runtime: On 32-bit applications, MSVC use 16 bit stack alignment whereas
MinGW uses 32-bit alignment. This is a common cause of segfaults for Python
extensions built with MinGW. Most developers just assume it is sufficient
to link the same CRT as Python. Another problem is the MinGW runtime
(mingw32.a or mingw32.dll) which conflicts with MSCV and can cause
segfaults unless it is statically linked. The vanlilla MinGW distro
defaults to dynamic linkage for this library. Because of this a special
MinGW toolchain was created for building SciPy on Windows:

https://github.com/numpy/numpy/wiki/Mingw-static-toolchain



Sturla



More information about the Python-Dev mailing list