From: spencer@panix.com (David Spencer)
Newsgroups: comp.sys.mac.programmer,comp.sys.atari.st.tech
Subject: Re: Sozobon (or other free C's): would this strategy work?
Date: 5 Jan 93 13:34:55 GMT
Distribution: comp
Organization: PANIX Public Access Unix, NYC

J R Evans (ngse18@castle.ed.ac.uk) proposes to port Sozobon C to the
Mac:

bobf@flint.geology.yale.edu (Bob Fischer) writes:

>If I were going to port a C to the Mac, I'd do GNU C, and port it "the
>right way".

...

>* GCC is a full (even extended) ANSI C language, ...

>* GCC is a very good compiler. ...

True; the 2.* versions are outstanding.

>* GCC runs on many systems

Everything I know of *except the Mac*.

>* GCC is backed by the Free Software Foundation.

However, a Mac port would get no support, and a lot of flames, from
the FSF. FSF expressly (and loudly) objects to Macs because of the
look-and-feel lawsuit. I personally think their stance is perverse
(Leninists deny the efficacy of the market, too, and look where it got
them).

So don't expect any help from FSF if you mention a Mac.

On the other hand, gcc has been ported to a/ux, so FSF's objections to
Macs are not an insuperable hurdle.

>* Finally, the most compelling reason is that I think that GCC would
>be the easiest to port!  GCC was written in a modular way, so that it
>can be ported to any system, running any instruction set.

>...  Since someone has already described the
>68000 instruction set to GCC, you would just have to modify the
>description, to make it work with the Mac quirks (like the special
>status of A5).

Indeed, you could start with the diffs for the a/ux port, which are
available at wuarchive.wustl.edu in systems/aux/gnu. Note that you'd
have to work around a number of nice unix features that MacOS lacks.
However, if gcc can be ported to something as braindead as ms/dos or
as Byzantine as vms, it has to be portable to Macs.

You'd have to build a new set of libraries, or figure out how to link
the MPW libs (and make users buy the MPW libs). If you have Think C,
you might be able to use the source that comes with it, although I
doubt Symantec would let you distribute their source or an object file
built from their source.

There is gnu source for a standard C library. Although it's for a
unix-based system, much of it is in (relatively) portable C and I
believe there is m68k-specific code. Of course, you'd have to roll
your own system-specific code, like memory allocation and stdio.

You also have to figure out how to make MacOS system calls. They use a
different (Pascalish) calling sequence. You've got to tell the
compiler how to set up the calls, and warn it with a "pascal" (or
similar) keyword.

Of course, you'd have to build or figure out how to link a library if
you ported any compiler, not just gcc.

>  To encourage people to port GCC, Richard Stallman
>(author of GCC) has written a 190-page manual describing in detail how
>to port GCC.  I don't believe any other program comes with such
>carefully written porting instructions.

A very nice book on practical compiler theory. Unfortunately (unless
I'm out of date), the manual is not up to date. The latest version of
the manual describes version 1.38, I think; the current version of the
compiler is 2.3. Because the basic theory of the compiler hasn't
changed, it should be adequate, though.


dhs   spencer@panix.com