target MacOS

Kai Ruottu
Mon Sep 6 03:41:00 GMT 1999

This was on a Mac newsgroup, so let's hope Stan Shebs doesn't
see something against forwarding it here:

------- Forwarded Message Follows -------
Date:          Tue, 4 May 1999 04:40:11 -0700
From:          Stan Shebs <>
Subject:       Re: GNU C available for MAC development ?

   From: (Kai Ruottu)
   Date: Tue, 04 May 1999 09:53:42 GMT

    I'm a little late in this thread, but after reading all the messages,
   the original question seems to be still fully unanswered...

    So, is it possible to build GNU C/C++ for compiling MacOS programs?

Yes, but only the version that is on the ftp site, and only native under
MPW.  In this respect the MacOS port is more like the HPUX or OSF/1
ports, where not all of the necessary pieces have been ported, and so
it's not possible to do full cross-compilation.

    My hosts for the (cross-) compiler would be Linux and Win32, not
   MacOS...  If the GNU tools work ok on a Mac, it doesn't help much
   when one hasn't a Mac....  I can build all things for DOS, Win32 and
   OS/2 under Linux with DOS/djgpp2.02, cygwin/mingw32 and emx
   cross-toolsets, so why MacOS should be a special 'closed system'?

Because back when I did this port, the people paying for it didn't
care about having a full cross-compilation setup to spend the extra
dollars, and so far nobody else has cared enough to set it up on their
own time.  Cygnus' Mac business was never large, but it evaporated
completely years ago - we don't even get calls anymore.  I think about
doing it on my own, but I also work on Xconq and on a free stamp
database (not yet announced), a third personal project would be too
much even if I thought it would have any users; but the lack of
volunteers tells me that there aren't enough Mac programmers left to
make it worthwhile.

    The organizing of the MPW libs & headers is a little weird for one
   used to see something like the 'crt0.o', 'libc.a', 'libm.a', but the
   Cygnus MPW docs tell what is needed when linking...  And the GNU
   binutils seem to handle the 'xcoff-powermac' format quite well...

    E:\usr\local\ppc-macos\lib>..\bin\objdump -p PPCStdCLib.o

    PPCStdCLib.o:     file format xcoff-powermac

That's true, BFD does know about the flavor of XCOFF used on PowerMacs.

    Moving the 'powerpc-macos' config files from older 2.7.x GCC releases
   (and probably changing some macros) to current egcs-1.1.2 went quite
   well too, but the linking phase seems to be the hardest...

Hmmm, did you collect all the diffs in the main sources?  There are some
patches that are important to compiling Mac apps, but that have never been
contributed to egcs (it didn't exist at the time).  It's been a long time,
I don't remember all of them though... They may not matter if you're
cross-compiling Unix-y code though.

    So, how one can use the 'StdCLib' and 'InterfaceLib' libraries in a
   cross-development environment?  The GNU bintools seem to not recognize
   the used format.

    E:\usr\local\ppc-macos\lib>..\bin\objdump -p StdCLib
    ..\bin\objdump: StdCLib: File format not recognized

    There is a weird text:

    0: 4A 6F 79 21 70 65 66 66  70 77 70 63 00 00 00 01  Joy!peffpwpc....
   10: B1 63 E7 E2 00 00 00 00  00 00 00 00 03 43 80 00  .c...........C..

This is the infamous PEF, whose format used to be secret but is now
published.  It's basically a compressed XCOFF, because basic XCOFF was
deemed too bloated.  It used to be that MacOS could run both XCOFF and
PEF executables, now they probably all have to be PEF.  I don't know
the origin of the header string, perhaps it refers to pleasure at the
smaller size of PEF files?  I remember that app size was a concern at
Apple at the time...

    If the 'StdCLib' and 'InterfaceLib' are some kind of shared libs,
   could the import libs for these be built with the GNU 'dlltool' ?

Hmmm.  Probably not.  The PowerMac runtime architecture is most similar
to AIX runtimes, in fact PowerMacs were bootstrapped from a bunch of
RS/6000 machines (thus the use of XCOFF for instance).  You would need
a tool to build PEF shlibs, but it could be done with a couple options
to ld, once you had the PEF BFD.

    All this is just pure experimenting, just wondered why the MacOS
   isn't supported as a target for cross-toolsets....

Just out of curiosity, do you have a particular motivation?  Making a
full cross-compiler is a major undertaking - I haven't even mentioned
the resource fork yet, and it's essential to the Mac runtime - and it
would hard to justify the effort unless you had a specific application
you needed to get onto the Mac.  Even so, if you were really committed,
I would be glad to pass along what I know about the issues in setting
up full cross-compilation to the Mac.  It's never been done - even
Apple's own bootstrapping system was pretty creaky and stopped working
years ago - so it would be a real coup for GNU.


------- Forwarded Message Ends -------

 Here should be facts for MacOS-target hackers...

Cheers, Kai

Want more information?  See the CrossGCC FAQ,
Want to unsubscribe? Send a note to

More information about the crossgcc mailing list