Mac OS X cross-compiler coming soon to a Fedora near you (or maybe not?)

Erik van Pienbroek erik at vanpienbroek.nl
Mon Jun 15 13:30:30 UTC 2009


Hi all,

In the last two weeks I've been experimenting with getting a Mac OS X
cross-compiler operational on Fedora. This was done according to
documentation [1] which Richard W.M. Jones mentioned [2] on the mailing
list some weeks ago.

The documentation uses mostly open source tools (odcctools [3] and GCC
[4]) but the Mac OS X SDK from Apple is also used. The Mac OS X SDK is
part of XCode which can be downloaded from the Apple website by
registered users [5]. The SDK contains headers and libraries which are
needed to compile applications for regular Mac OS X environments.

There are two different SDK's which can be used. There's one for Mac OS
X 10.4 (Tiger) and one for Mac OS X 10.5 (Leopard). There are also two
versions of GCC available, GCC 4.0 and GCC 4.2. For my experiments I
used the 10.4 SDK and GCC 4.2 (GCC 4.0 failed to compile because of a
strange error in the libstdc++ configure script).

I managed to translate the documentation into several .spec files so
that everything integrates nicely in Fedora. I've also ported several
mingw packages to this toolchain so that GTK based applications can be
tested on a Mac OS X environment. The complete list of packages is:

darwinx-filesystem
darwinx-odcctools
darwinx-sdk
darwinx-gcc
darwinx-gettext
darwinx-libpng
darwinx-libjpeg
darwinx-jasper
darwinx-pixman
darwinx-cairo
darwinx-glib2
darwinx-atk
darwinx-pango
darwinx-gtk2
darwinx-libsoup
darwinx-gtkhtml
darwinx-ige-mac-integration
darwinx-gtk-quartz-engine

This is also the order in which the packages need to be compiled.

In this list there are some new packages which aren't in Fedora-MinGW.

The first one is darwinx-gtkhtml. The MinGW variant of this package
isn't in Fedora yet because it is heavily patched to drop all the
(unnecessary) GNOME dependencies. The patch is too ugly right now for
inclusion in the Fedora-MinGW project and needs to be cleaned up.

Two other new packages are darwinx-ige-mac-integration and
darwinx-gtk-quartz-engine. These are two GNOME projects [6][7] which
make GTK integrate better in Mac OS X environments.

All the srpms for these packages can be found at [8]. The srpm for
darwinx-sdk is missing. This is done on purpose because the XCode
package itself is about 1GB in size. The .spec file and other
sources/patches for the SDK are placed in a separate folder. The
resulting .noarch.rpm of the SDK is also placed in that folder (which is
32MB in size).

Now about the results: With this toolchain I managed to get one of my
personal open source projects, NNTPGrab [9], operational, but there are
still some strange bugs involved. This project is a GTK based
application which makes use of GObject signals. In my first try on the
Mac OS X toolchain, the signals were emit, but the parameters in the
callback functions were always NULL. After that I dropped some
potentially conflicting files from the SDK (headers installed by GCC)
and rebuild everything. Now the GObject signals work fine, but the fonts
are really messed up. It's basically the same as described in a WebKit
bug report [10] as I've also seen the same error message while running
my application. Unfortunately I don't have a solution to that yet, but I
suspect it's caused by a compiler mismatch (Mac OS X 10.4 is based on
GCC 4.0 while Mac OS X 10.5 is based on GCC 4.2).

Another technical issue which I haven't thought of yet is the use of fat
binaries/univeral binaries [11]. With fat binaries the application can
be run on multiple architectures like ppc, x86 and x86_64. It requires
multiple cross compilers which are bundled together using special
compiler flags. For now I've only prepared a i686-apple-darwin9
toolchain.

On to everybody's favorite subject (ahum..), the legal stuff.
First of all, I didn't do a thorough research yet about all the licenses
involved. For GCC and odcctools I don't see any license
incompatibilities which prevent it from inclusion in Fedora.

The Mac OS X SDK seems to be a mix a various licenses. I've seen files
with the following licenses:
- Apple Public Source License version 1.0
- Apple Public Source License version 1.1
- Apple Public Source License version 2.0
- GPLv2+

According to [12] and [13] the APSL 1.0 and 1.1 licenses are a no-go for
Fedora, so that may indicate the whole project isn't welcome in Fedora..
We could try to extract all the APSL 2.0 and GPLv2+ pieces from the SDK,
but I'm afraid it won't be enough to compile regular applications.

Another issue we have is that the SDK contains several libraries which
are needed to compile regular applications. The source code for a number
of these libraries isn't open source so that may also be another reason
why the SDK isn't welcome in Fedora.

To wrap it all up, it's technically possible to cross-compile Mac OS X
applications but there are still some major roadblocks up ahead.

Regards,

Erik van Pienbroek


[1]:  http://devs.openttd.org/~truebrain/compile-farm/apple-darwin9.txt
[2]:
http://lists.fedoraproject.org/pipermail/fedora-mingw/2009-May/001327.html
[3]:  http://code.google.com/p/iphone-dev/
[4]:  http://opensource.apple.com/release/developer-tools-312/
[5]:  http://developer.apple.com/mac/
[6]:  http://live.gnome.org/GTK%2B/OSX/Integration
[7]:  http://sourceforge.net/apps/trac/gtk-osx/wiki
[8]:  http://build2.openftd.org/darwinx/
[9]:  http://www.nntpgrab.nl
[10]: https://bugs.webkit.org/show_bug.cgi?id=24220 
[11]: http://wiki.openttd.org/Universal_libraries
[12]:
https://www.redhat.com/archives/fedora-legal-list/2009-February/msg00009.html
[13]: https://fedoraproject.org/wiki/Licensing:Main#Bad_Licenses






More information about the mingw mailing list