[Patches] [ python-Patches-1053879 ] mingw compile

SourceForge.net noreply at sourceforge.net
Mon Mar 7 11:29:04 CET 2005


Patches item #1053879, was opened at 2004-10-25 18:38
Message generated for change (Comment added) made by kramm
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1053879&group_id=5470

Category: Core (C code)
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Matthias Kramm (kramm)
Assigned to: Martin v. Löwis (loewis)
Summary: mingw compile

Initial Comment:
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


----------------------------------------------------------------------

>Comment By: Matthias Kramm (kramm)
Date: 2005-03-07 11:29

Message:
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 at python.org. But for now, as that's what the
current implementation does, this patch is consistent with
that approach.

Greetings

Matthias


----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2005-03-04 14:59

Message:
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?

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2004-11-01 11:14

Message:
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?

----------------------------------------------------------------------

Comment By: Matthias Kramm (kramm)
Date: 2004-11-01 09:28

Message:
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.


----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2004-11-01 03:21

Message:
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

----------------------------------------------------------------------

Comment By: Matthias Kramm (kramm)
Date: 2004-10-31 10:11

Message:
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).


----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2004-10-31 06:40

Message:
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.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1053879&group_id=5470


More information about the Patches mailing list