Created on 2011-03-30 16:21 by moog, last changed 2011-03-31 22:13 by schmir.
|msg132595 - (view)||Author: Jason Morgan (moog)||Date: 2011-03-30 16:21|
Bulding a simple extension (the spam example) fails with mingw64. in modsupport.h, the following is used to detect 64bit, it does not work with mingw64. #if SIZEOF_SIZE_T != SIZEOF_INT /* On a 64-bit system, rename the Py_InitModule4 so that 2.4 modules cannot get loaded into a 2.5 interpreter */ #define Py_InitModule4 Py_InitModule4_64 #endif This code never compiles, you can test this by placing similar code and filling it with rubbish. This means it thinks the extension is being built on a 32bit compiler and creates the wrong call for Py_InitModule. Workaround: Explicitly calling Py_InitModule4_64() in extension and declaring Py_InitModule4_64(...) in code. Note this does not complain about re-declaration and builds OK because declaration is wrong. e.g. //m=Py_InitModule("spam", SpamMethods); m = Py_InitModule4_64("spam", SpamMethods,(char *)NULL, (PyObject *)NULL, PYTHON_API_VERSION); Or, a better more portable permanent fix, define WIN64 in code and modify modsupport.h: #if SIZEOF_SIZE_T != SIZEOF_INT || defined(WIN64) /* On a 64-bit system, rename the Py_InitModule4 so that 2.4 modules cannot get loaded into a 2.5 interpreter */ #define Py_InitModule4 Py_InitModule4_64 #endif I am sure there are other, more standard ways.
|msg132599 - (view)||Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) *||Date: 2011-03-30 18:07|
What are the values of SIZEOF_SIZE_T and SIZEOF_INT with this compiler? I'd expect them to be respectively 8 and 4.
|msg132639 - (view)||Author: Jason Morgan (moog)||Date: 2011-03-31 08:34|
OK, I've understood this a bit more. The compiler does not cause pyconfig.h to define SIZEOF_SIZE_T and SIZEOF_INT, rather it is the definition of MS_WIN64 at compile time (which was not being defined) Defining MS_WIN64 fixes the problem, and causes another unrelated one.... I would guess that I would have to change the patch in Issue11723 to define MS_WIN64, how do I then use the same compiler for 32BIT? What is the correct way to pass such flags to the compiler class?
|msg132715 - (view)||Author: Ralf Schmitt (schmir)||Date: 2011-03-31 22:13|
pyconfig.h defines SIZEOF_SIZE_T depending on the preprocessor symbol MS_WIN64. The patch in #4709 would fix that.
messages: + msg132715
|2011-03-31 08:34:56||moog||set||messages: + msg132639|
messages: + msg132599