Cross platform compilation?

Nick Craig-Wood nick at craig-wood.com
Wed Feb 4 04:31:59 EST 2009


Christian Heimes <lists at cheimes.de> wrote:
>  John Harper schrieb:
> > I am trying to build Python to use in an embedded system which uses a 
> > ppc_440 CPU. The only information I've found is something written by 
> > Klaus Reimer a few years ago, which was based on Python 2.2. So far I 
> > seem to have successfully built Python itself, but building the 
> > extensions fails miserably with complaints about library format. It 
> > insists on referring to "i686" which is indeed the platform it is 
> > actually running on.
> > 
> > Before I try to reverse engineer completely setup.py, is there 
> > something obvious that needs to be done to get it to use the right tool 
> > chain?

I spent some time mucking about trying to do this for ARM.  I almost
got it to work using qemu but not quite!  What I did in the end was to
use a pre-compiled python (from debian) then copy the headers and
library files into the cross compiling environment so we could embed
python into our code and build our extensions.

> > More generally, it seems like this would be something that lots of 
> > people would want to do. I'm surprised there isn't support for it built 
> > into the distributed version of Python, without having to hack all the 
> > setup files...?
> 
>  I'm sorry to inform you that Python doesn't support cross platform
>  compilation. Python eats its own dog food and uses Python to compile
>  optional extension modules.

It isn't an impossible problem...

If you've ever cross compiled gcc you'll find that it first uses the
host compiler (possibly not gcc) to compile itself to make a gcc which
runs on the host but makes code for the target.  It then uses that new
compiler to compile a gcc for the target architecture.

I could imagine a similar scheme for python, but it would involve lots
of fiddling about and some commitment from the python maintainers.

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list