Building and using GCC 0.9 aka the first public version

In my quest for old software, I’ve seen this file in multiple searches, gcc-0.9.tar.bz2, which is the first version of GCC!

article from virtuallyfun.superglobalmegacorp.com

GCC 0.9 on SIMH VAX / 4.2BSD

GCC 0.9 on SIMH VAX / 4.2BSD

From the original announcement:

 Date: Sun, 22 Mar 87 10:56:56 EST
From: rms (Richard M. Stallman)

   The GNU C compiler is now available for ftp from the file
/u2/emacs/gcc.tar on prep.ai.mit.edu.  This includes machine
descriptions for vax and sun, 60 pages of documentation on writing
machine descriptions (internals.texinfo, internals.dvi and Info
file internals).

   This also contains the ANSI standard (Nov 86) C preprocessor and 30
pages of reference manual for it.

   This compiler compiles itself correctly on the 68020 and did so
recently on the vax.  It recently compiled Emacs correctly on the
68020, and has also compiled tex-in-C and Kyoto Common Lisp.
However, it probably still has numerous bugs that I hope you will
find for me.

   I will be away for a month, so bugs reported now will not be
handled until then.

   If you can’t ftp, you can order a compiler beta-test tape from the
Free Software Foundation for $150 (plus 5% sales tax in
Massachusetts, or plus $15 overseas if you want air mail).

   Free Software Foundation
1000 Mass Ave
Cambridge, MA  02138

[tapes are generally in Unix tar format.  If you have other needs,
write to the above address, and ask if they can be met. -len]

And indeed, the files are dated 22/03/1987 making this the first public release of GCC.

GNU CC is a fairly portable optimizing C compiler intended for
machines with 32-bit words that have several registers and address
memory in terms of 8-bit bytes.  It supports full ANSI standard C, not
including libraries (which we do not consider to be part of a
compiler).
Currently we have working machine descriptions for the Vax and for
the 68000/68020 (including 68881 support).
Optimizations performed by GNU CC include:

  • Invariant code motion out of loops.
  • Common subexpression elimination.
  • Automatic register packing (register declarations are unnecessary
    and ignored).
  • Constant propagation and elimination of consequent dead code.
  • Copy propagation.
  • Elimination of dead stores.
  • Jump optimization including cross-jumping.
  • Delaying of stack adjustments after function calls.
  • Arithmetic performed in subword types when appropriate.
  • Many local optimizations.

GNU CC runs about as fast as PCC.
Most of the optimizations are machine-independent or controlled by a
machine description.  GNU CC takes advantage of all the 68020
addressing modes that we can see how to make the Sun assembler
assemble.  Debugging output for DBX is available whether you request
optimization or not.

Seeing as 4.3BSD didn’t ship until 1988, I went ahead and set out to build this on 4.2BSD. The first stumbling block I hit is that GCC needs bison.  The oldest version of bison I have is 1.25 which honestly is just too new!  However in the same location as GCC is this file gnu1988.tar.bz2 which contains all of the current GNU software of 1988!  And what is on that tape?

  • bison-1.00
  • gcc-1.21
  • gdb-2.5.1
  • gplusplus-1.21
  • libgplusplus

So this is probably as old as it is going to get, so I downloaded and went to compile bison, however getopt is a missing call!  A creative search found getopt.c (local mirror) and even better PCC liked it enough to get a running bison so I could then configure GCC.

Configuring GCC is a manual process, but not too involved:

  • Make a symbolic link from file `config.h’ to the top-level
    config file for the machine you are using. Its name should be
    `config-MACHINE.h’. This file is responsible for
    defining information about the host machine. It includes
    `tm.h’.
  • Make a symbolic link from `tm.h’ to the machine-description
    macro file for your machine (its name should be
    `tm-MACHINE.h’).
  • Make a symbolic link from `md’ to the
    machine description pattern file (its name should be
    `MACHINE.md’)
  • Make a symbolic link from
    `aux-output.c’ to the output-subroutine file for your machine
    (its name should be `MACHINE-output.c’).Make sure the Bison parser generator is installed.Build the compiler. Just type `make’ in the compiler directory.

And in a minute I had GCC compiled.  I ran it with -v and got this output:

# gcc -v
ld /lib/crt0.o -lc
Undefined:
_main

It really is nowhere near as featured as 1.21 that is for sure!  So time to do a simple hello world program:

# cat hello.c
#include <stdio.h>
void main(){
printf(“GCC 0.9 in action!\n”);
}
# gcc -v hello.c -o hello
cpp -Dvax hello.c /tmp/cc002050.cpp
cc1 /tmp/cc002050.cpp -quiet -dumpbase hello.c -noreg -o /tmp/cc002050.s
as -o hello.o /tmp/cc002050.s
ld -o hello /lib/crt0.o hello.o -lc
# ./hello
GCC 0.9 in action!

And there we go!

I don’t know why, but I haven’t seen anything about anyone actually running GCC 0.9.  Or even where or how they found this ‘lost’ file.  Let alone anyone even building or running it in 2016.

For anyone who wants to try, SIMH tape files of the binaries are here:

And of course source tapes are here.

9 thoughts on “Building and using GCC 0.9 aka the first public version

    • I went ahead and tried the oldest version of GAS I could find, 1.19 that identifies as “Gnu assembler version 1.19 (I guess.)”… Anyways it’s very buggy unfortunately. I can compile simple stuff like hello world fine, but trying to build bison it injects blank symbols, when building with GCC, and building with CC it fails to assemble entire blocks.

      I guess the solution is to simply use a later version, but I guess it’s worth knowing on 4.2BSD at any rate it doesn’t work that well on the VAX. I suspect it may fare better on the 68020 based SUN-2 kit that I think they used in the FSF in the mid to late 1980s.

      • Back in the day, I would use the GNAT Ada packages as they relied on GCC! I’d written a convaluted process that I illustrated on an emulated sparc, but I’ve done on RS/6000 power and PowerPC and HPPA.

        https://virtuallyfun.com/wordpress/2010/05/04/200th-post-and-using-ada-to-fix-your-system/

        If you are comfortable with unixy commands it’s pretty simple, and it gives you a leg up.

        PCC supports 64 bit ISA so I’m not sure if that will help.

        I’ve rebuilt GCC v1 and 2 using MinGW GCC v3, 5 and 7.. There is a couple of weird things but it’s not impossible. Be sure to keep an old bison and flex handy. I’ve used the tool chains to build Linux kernels without much fail, the hardest thing is the Linux tools to convert the kernels to bootable images.

        If you have issues let me know I’ll see what I can do!

        Good luck!

  1. Will this compileer, compiler unchanged K&R C such as to be found in the my copy of Whitebook First Edition.(1970)? Forget about “C designed by committees”;
    I need a real K&R C compiler for SPARC (up to V9) and MC68000 series to MC68040 will this go even part way to compiling for these processor families??

    • The problem you will face is that the SPARC came along much later. If you run SunOS it’ll have that SUN compiler derivative. PCC the portable C compiler, PCC, has sparc64 support, although it was added later. SPARC support was added in GCC 1.36, back in 1989.

      For old SPARC & 68020 GCC 1.40 will do it, GCC 2.x will support more modern processor (at least 030) and K&R.

      If you have sources greenhill will most defiantly support it,I guess the real question is what system are you planning to build from?

  2. hi, thank you for replying and relating history of gcc versions and which may still do K&R C. back in the late 1980s early 1990s remember compiling linux and gcc took ages on early AMD chip based machines. It is more a question for which CPU/platform can I get a K&R C compiler that can compile itself hopefully in K&R C rather than pick the platform/CPU and find a K&R C compiler. I have Solaris 8 running on spark-v9 machine that has a command line arrow key bug still looking at. The Sun C compiler and Sun lint certainly do not like “raw” K&R C straight from the Whitebook. But not a big job to get it to compiler and run OK.
    I am in the process of downloading sources for various gcc’s to look at what changes were made to bring it up on sparc, and will have a look at pcc too.
    thanks again (dja.)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.