This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: mingw compile
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: loewis Nosy List: kramm, loewis, rhettinger
Priority: normal Keywords: patch

Created on 2004-10-25 16:38 by kramm, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
xmingw32.patch kramm, 2004-10-25 16:38 xmingw32.patch
posixmodule.c kramm, 2004-11-01 08:28 Modules/posixmodule.c (fixed)
Messages (10)
msg47136 - (view) Author: Matthias Kramm (kramm) Date: 2004-10-25 16:38
A cross-compile of a Win32 Python under Linux using
MingW (www.mingw.org) didn't work, as posixmodule.c
didn't know anything about MingW.
This patch fixes the various compile errors by
introducing a new local MINGW define in posixmodule.c,
and making several #ifdefs also take that variable into
account.

After this patch is applied, it's possible to compile
python.exe on Linux with MingW by doing

 CXX=i386-mingw32msvc-g++ \
 CPP=i386-mingw32msvc-cpp \
 RANLIB=i386-mingw32msvc-ranlib \
 AR=i386-mingw32msvc-ar \
 CC="/opt/xmingw/bin/i386-mingw32msvc-gcc -DMS_WINDOWS
-DPy_WIN_WIDE_FILENAMES" \
 ./configure --host=i586-mingw32msvc 

 sed -i s/initposix/initnt/g Modules/config.c
 sed -i 's/#define HAVE_DEV_PTMX 1//g' pyconfig.h
   
 make
msg47137 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-10-31 05:40
Logged In: YES 
user_id=80475

Please attach a new posixmodule.c instead of the diff file.
 For some reason, my patch tool thinks the formatting is
malformed.
msg47138 - (view) Author: Matthias Kramm (kramm) Date: 2004-10-31 09:11
Logged In: YES 
user_id=1146139

Ok, I've attached the full posixmodule.c.
It's based on the lastest CVS version (2.329, from 2004/10/13).
msg47139 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-11-01 02:21
Logged In: YES 
user_id=80475

I don't have a way of testing your patch and will have to
apply it on blind faith.  Be sure to get it right and read
it carefully to make sure it doesn't mess-up anyone else's
compilation.

The attached version won't compile for me (MSVC++ 6.0 on WinMe):

posixmodule.c
C:\py24\Modules\posixmodule.c(1175) : warning C4013:
'ttyname' undefined; assuming extern returning int
C:\py24\Modules\posixmodule.c(1175) : warning C4047: '=' :
'char *' differs in levels of indirection from 'int '
C:\py24\Modules\posixmodule.c(1660) : error C2065: 'DIR' :
undeclared identifier
C:\py24\Modules\posixmodule.c(1660) : error C2065: 'dirp' :
undeclared identifier
C:\py24\Modules\posixmodule.c(1660) : warning C4552: '*' :
operator has no effect; expected operator with side-effect
C:\py24\Modules\posixmodule.c(1661) : error C2143: syntax
error : missing ';' before 'type'
C:\py24\Modules\posixmodule.c(1662) : error C2143: syntax
error : missing ';' before 'type'
C:\py24\Modules\posixmodule.c(1665) : error C2065:
'arg_is_unicode' : undeclared identifier
C:\py24\Modules\posixmodule.c(1670) : warning C4013:
'opendir' undefined; assuming extern returning int
C:\py24\Modules\posixmodule.c(1670) : warning C4047: '==' :
'int ' differs in levels of indirection from 'void *'
C:\py24\Modules\posixmodule.c(1674) : warning C4013:
'closedir' undefined; assuming extern returning int
C:\py24\Modules\posixmodule.c(1678) : error C2065: 'ep' :
undeclared identifier
C:\py24\Modules\posixmodule.c(1678) : warning C4013:
'readdir' undefined; assuming extern returning int
C:\py24\Modules\posixmodule.c(1678) : warning C4047: '!=' :
'int ' differs in levels of indirection from 'void *'
C:\py24\Modules\posixmodule.c(1679) : error C2223: left of
'->d_name' must point to struct/union
C:\py24\Modules\posixmodule.c(1680) : error C2223: left of
'->d_namlen' must point to struct/union
C:\py24\Modules\posixmodule.c(1681) : error C2223: left of
'->d_name' must point to struct/union
C:\py24\Modules\posixmodule.c(1681) : error C2223: left of
'->d_namlen' must point to struct/union
C:\py24\Modules\posixmodule.c(1683) : error C2223: left of
'->d_name' must point to struct/union
C:\py24\Modules\posixmodule.c(1683) : error C2223: left of
'->d_namlen' must point to struct/union
C:\py24\Modules\posixmodule.c(1683) : error C2198:
'PyString_FromStringAndSize' : too few actual parameters
C:\py24\Modules\posixmodule.c(2860) : warning C4013: 'fork'
undefined; assuming extern returning int
C:\py24\Modules\posixmodule.c(2986) : warning C4013:
'getegid' undefined; assuming extern returning int
C:\py24\Modules\posixmodule.c(2999) : warning C4013:
'geteuid' undefined; assuming extern returning int
C:\py24\Modules\posixmodule.c(3012) : warning C4013:
'getgid' undefined; assuming extern returning int
C:\py24\Modules\posixmodule.c(3134) : warning C4013:
'getppid' undefined; assuming extern returning int
C:\py24\Modules\posixmodule.c(3176) : warning C4013:
'getuid' undefined; assuming extern returning int
C:\py24\Modules\posixmodule.c(3206) : warning C4013: 'kill'
undefined; assuming extern returning int
C:\py24\Modules\posixmodule.c(4959) : warning C4013: 'wait'
undefined; assuming extern returning int
msg47140 - (view) Author: Matthias Kramm (kramm) Date: 2004-11-01 08:28
Logged In: YES 
user_id=1146139

Thanks for testing this with MSVC++.
You're right- the patch did break VC compilation (There was
an #else missing in the big recursive #ifdef block on line 80).

I'll attach a fixed version (and delete the old version).
I've scrutinized the new version several times to make sure
there aren't any other issues.
msg47141 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-11-01 10:14
Logged In: YES 
user_id=80475

Martin, I have no way of testing this further.  The diff
looks fine to my eye.   I would like to apply it before the
beta so that any problems would surface right away.  Do you
have any issues with the patch that I might not have thought
about?
msg47142 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-03-04 13:59
Logged In: YES 
user_id=21627

I don't understand why the patch is necessary. Why doesn't
autoconf determine that all these functions are present?
msg47143 - (view) Author: Matthias Kramm (kramm) Date: 2005-03-07 10:29
Logged In: YES 
user_id=1146139

That's a problem which isn't introduced by this patch.
In posixmodule.c, a lot of code fragments already read like

#if _THISORTHATCOMPILER_
#define HAVE_FUNCTION_FOO
#define HAVE_FUNCTION_BAR
#endif

That is, autoconf only determines the used compiler, and
posixmodule.c uses that to make assumptions about which
functions are present.
That's also exactly what breaks MingW compilation- as
posixmodule.c doesn't know anything about MingW as compiler,
it defaults on gcc, and hence derives the wrong set of
available functions.

This patches fixes that in making posixmodule.c "MingW-aware".

I don't know why posixmodule.c was implemented in that way,
instead of making autoconf determine all those HAVE_ flags-
maybe that's a question which should go to
python-dev@python.org. But for now, as that's what the
current implementation does, this patch is consistent with
that approach.

Greetings

Matthias
msg47144 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-03-07 21:12
Logged In: YES 
user_id=21627

Please read the code carefully. The "this or that compiler"
tests are primarily used in environments which *don't* use
autoconf. For all other systems, configure does detect all
the HAVE_ variables - see pyconfig.h.in. As "using MingW on
Linux" should be an autoconf-based process, you should make
sure that process works correctly.

msg47145 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2006-01-03 07:14
Logged In: YES 
user_id=21627

Rejecting the patch due to lack of response from submitter.
If you ever want to work on it again, please create a new
patch in the tracker.
History
Date User Action Args
2022-04-11 14:56:07adminsetgithub: 41076
2004-10-25 16:38:33krammcreate