[Patches] [ python-Patches-1597850 ] Cross compiling patches for MINGW

SourceForge.net noreply at sourceforge.net
Wed Dec 6 21:12:23 CET 2006

Patches item #1597850, was opened at 2006-11-16 17:57
Message generated for change (Comment added) made by loewis
You can respond by visiting: 

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Build
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Han-Wen Nienhuys (hanwen)
Assigned to: Nobody/Anonymous (nobody)
Summary: Cross compiling patches for MINGW

Initial Comment:

attached tarbal is a patch bomb of 32 patches against python 2.5, that we lilypond developers use for crosscompiling python.  The patches were originally written by Jan Nieuwenhuizen, my codeveloper.

These patches have been tested with Linux/x86, linux/x64 and macos 10.3  as build host and   linux-{ppc,x86,x86_64}, freebsd, mingw as target platform. All packages at  lilypond.org/install/ except for darwin contain the x-compiled python.

Each patch is prefixed with a small comment, but for reference, I include a snippet from the readme.

It would be nice if at least some of the patches were included. In particular, I think that X-compiling is a common request, so it warrants inclusion.

Basically, what we do is override autoconf and Makefile settings through setting enviroment variables.

**README section** 

Cross Compiling

Python can be cross compiled by supplying different --build and --host
parameters to configure.  Python is compiled on the "build" system and
executed on the "host" system.  Cross compiling python requires a
native Python on the build host, and a natively compiled tool `Pgen'.

Before cross compiling, Python must first be compiled and installed on
the build host.  The configure script will use `cc' and `python', or
environment variables CC_FOR_BUILD or PYTHON_FOR_BUILD, eg:

   CC_FOR_BUILD=gcc-3.3 \
   PYTHON_FOR_BUILD=python2.4 \
   .../configure --build=i686-linux --host=i586-mingw32

Cross compiling has been tested under linux, mileage may vary for
other platforms.

A few reminders on using configure to cross compile:
- Cross compile tools must be in PATH,
- Cross compile tools must be prefixed with the host type
  (ie i586-mingw32-gcc, i586-mingw32-ranlib, ...),
- CC, CXX, AR, and RANLIB must be undefined when running configure,
  they will be auto-detected.

If you need a cross compiler, Debian ships several several (eg: avr,
m68hc1x, mingw32), while dpkg-cross easily creates others.  Otherwise,
check out Dan Kegel's crosstool: http://www.kegel.com/crosstool .


>Comment By: Martin v. Löwis (loewis)
Date: 2006-12-06 21:12

Logged In: YES 
Originator: NO

One more note: it would be best if the patches were against the subversion
trunk. They won't be included in the 2.5 maintenance branch (as they are a
new feature), so they need to be ported to the trunk, anyway.


Comment By: Martin v. Löwis (loewis)
Date: 2006-12-06 21:06

Logged In: YES 
Originator: NO

I'll add my comments as I go through the patches.

- why is there now a mingw32msvc2 platform? If the target is mingw (rather
than Cygwin), I'd expect that the target is just Win32/Windows, and that
all symbolic constants provided be usable across all Win32 Pythons.
- why is h2py run for /usr/include/netinet/in.h? Shouldn't it operate on a
target header file?
- please include any plat-* files that you generate in the patch.
- why do you need dl_nt.c in Modules? Please make it use the one from PC
(consider updating the comment about
calling initall)

- please combine all patches adding support for __MINGW32__ into a single
one. Why is anything needed here at all? I thought Python compiles already
with mingw32 (on Windows)?
- what is the exclusion of freezing for?

- Why are you taking timeval from winsock2.h? It should come from
sys/time.h, and does in my copy of Debian mingw32-runtime.

- Why are these changes needed? It's Windows, and that is already

- Why doesn't that already work on Windows+cygwin+mingw32?

- I think this should target msvcr71.dll, not msvcrt.dll

Please also combine the cross-compilation patches into a single one.
- there is no need to provide pyconfig.h.in changes; I'll regenerate that,

- please integrate those into the large AC_CHECK_FUNCS that already

- Why are you stripping -Wl?

- Try getting SO from the Makefile, not from the environment (I assume
this is also meant to support true distutils packages some day).

- again: what is the "mingw" platform?

- is this really necessary? I suggest to drop it

- don't include bits/time.h; it's not meant for direct inclusion

- what's a .x file?


Comment By: Han-Wen Nienhuys (hanwen)
Date: 2006-11-25 16:12

Logged In: YES 
Originator: YES

I've sent the agreement by snailmail.


Comment By: Jan Nieuwenhuizen (janneke-sf)
Date: 2006-11-17 20:57

Logged In: YES 
Originator: NO

I do not mind either.  I've just signed and faxed contrib-form.html.


Comment By: Han-Wen Nienhuys (hanwen)
Date: 2006-11-17 01:33

Logged In: YES 
Originator: YES

note that not all of the patch needs to go in its current form. In
particular, setup.py should be
much more clever to look into build-root for finding libs and include


Comment By: Han-Wen Nienhuys (hanwen)
Date: 2006-11-17 01:32

Logged In: YES 
Originator: YES

I don't mind, and I expect Jan won't have a problem either.

What's the procedure: do we send the disclaimer first, or do you do the
review, or does everything happen in parallel?



Comment By: Martin v. Löwis (loewis)
Date: 2006-11-16 22:47

Logged In: YES 
Originator: NO

Would you and Jan Nieuwenhuizen be willing to sign the contributor
agreement, at


I haven't reviewed the patch yet; if they can be integrated, that will
only happen in the trunk (i.e. not for 2.5.x).


You can respond by visiting: 

More information about the Patches mailing list