More notes on Darwin porting
Richard W.M. Jones
rjones at redhat.com
Mon Feb 16 08:03:10 UTC 2009
I had a chance yesterday to have a closer look a the darwinx-gcc
compilation failure.
The cause turned out to be relatively simple: odcctools is riddled
with 32 bit assumptions. For example, it expects the return value
from malloc/calloc/etc to fit into a 32 bit unsigned int, which was
the immediate cause of the segfault in the assembler. No one has made
a serious attempt to port odcctools to 64 bit, but this isn't a
problem as I was able to recompile it with "gcc -m32" and it works
fine. You can find the 32 bit compiled version in the repository.
However a larger problem emerged: we are not able to compile libgcc
(part of the gcc runtime). It depends on files in the Darwin runtime
such as /usr/lib/crt1.o and dylib1.o. We would need to cross-compile
these, creating a darwinx-runtime package.
Now these runtime files are open source -- kinda. Apple distributes
them in the Csu package[1] which is under the APSL 1.0. This license
is listed under Bad Licenses here[2], but you should note that this
list includes both non-free licenses AND deprecated licenses (APSL
latest is 2.0), and I have not determined which category this falls
under.
[1] http://www.opensource.apple.com/darwinsource/
[2] http://fedoraproject.org/wiki/Licensing#Bad_Licenses
In the worst case we would need to reimplement the functionality of
Apple's Csu package. Luckily it's only a few hundred lines of
assembler. Unluckily I've looked at it now, so I can't do it --
someone else will have to step up to do this.
There are also some apparently free reimplementations. I have not
checked the code and license in detail, but see for example:
http://pcc.ludd.ltu.se/fisheye/browse/pcc/pcc-libs/csu/darwin/i386/crt0.c?r=1.1
libgcc also needs /usr/lib/libsystem.B.dylib. I haven't checked the
status of this library, but because we only need some dynamic library
to link against, we can just create one containing the right dummy
stub symbols.
Rich.
--
Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v
More information about the mingw
mailing list