
Building and using a 29-year-old compiler on a modern system - ingve
https://miyuki.github.io/2017/10/04/gcc-archaeology-1.html
======
awirth
Getting old build tools to work is really awesome. I went through a similar
process getting an old version of HPHPc (the PHP-to-c compiler precursor to
HHVM) to work[1]. I found Docker to be incredibly invaluable for doing this in
a reproducible way, especially when the system state needed to be changed in
complex ways or dependencies needed to be tweaked.

A small example is that the test cases only work right if English, German,
Finnish and French locales are available and if the system timezone is set to
"America/Los_Angeles".

[1]: [https://github.com/allanlw/hphpc-
docker](https://github.com/allanlw/hphpc-docker)

~~~
megaman22
Another fun one is:
[http://fabiensanglard.net/Compile_Like_Its_1992/index.php](http://fabiensanglard.net/Compile_Like_Its_1992/index.php)

------
userbinator
Note that the gcc.gnu.org server, like many others, is configured to also
serve the same files via HTTP(S) e.g.

[https://gcc.gnu.org/pub/gcc/old-
releases/gcc-1/gcc-0.9.tar.b...](https://gcc.gnu.org/pub/gcc/old-
releases/gcc-1/gcc-0.9.tar.bz2)

It's actually a little surprising just how much code is already there even in
such an early pre-ISO-C version --- it feels like GCC was rather
overengineered from the beginning.

~~~
pavlov
Was it overengineered, or is this one of the rare cases where "too much"
architecture upfront was actually a sound long-term investment?

GCC is still around and kicking and competes well with the much more modern
Clang that has substantial investment from Apple and other industry giants.
That's an amazing achievement for a 30-year-old open source project.

~~~
eru
Politics bear a part of the blame for some of GCC's more questionable
architectural decisions. They intentionally made the architecture hard to
write plugins for.

~~~
anitil
For the ignorant: what decisions are you referring to? I've heard this a lot
but am not sure what people mean.

~~~
eru
[https://news.ycombinator.com/item?id=15408652](https://news.ycombinator.com/item?id=15408652)
explains it better than I did. Basically, early on they didn't want GCC to be
able to be used piecemeal with closed source compilers / plugins. Thus they
made GCC hard to be used piecemeal.

But using bits and pieces of your compiler is exactly what you'd want to be
doing when you want to have good editor integration: eg syntax highlighting
_should_ actually use the compiler instead of duplicating logic. Especially
with a language that's Turing complete to even parse like C++; the logic just
to figure out whether something is a type to be coloured eg blue or a variable
name to be coloured eg green.

(See [http://blog.reverberate.org/2013/08/parsing-c-is-
literally-u...](http://blog.reverberate.org/2013/08/parsing-c-is-literally-
undecidable.html))

------
drej
This is a post about a fun experiment, but these kinds of tasks are day to day
jobs for quite a few people. Fortran or COBOL codebases are often unmaintained
yet relied upon.

I remember when we updated our Fortran compilers (because of other tooling)
and they had problems with our 80s/early 90s code. That was joy to debug.

------
rasz
If you enjoy this type of content I highly recommend
[https://virtuallyfun.com](https://virtuallyfun.com)

Example cool article: [https://virtuallyfun.com/2015/10/09/building-
linux-0-11-on-w...](https://virtuallyfun.com/2015/10/09/building-
linux-0-11-on-windows-10/)

~~~
scruffyherder
Thanks for the plug, I've been able to cross build just about every a.out
buildable Linux kernel from Windows.

In addition I've built and did some minor tyre kicking with GCC 0.9

[https://virtuallyfun.com/2016/12/01/building-using-
gcc-0-90-...](https://virtuallyfun.com/2016/12/01/building-using-gcc-0-90-aka-
first-public-version/)

I've done minor shuffling to get DooM to compile with GCC 1.39 on MS-
DOS/x68000 & OS/2

[https://virtuallyfun.com/2017/07/29/null-doom-
gcc-1-39-go32-...](https://virtuallyfun.com/2017/07/29/null-doom-
gcc-1-39-go32-dpmi/)

GCC 1.37 on MacOS

[https://virtuallyfun.com/2016/05/24/gcc-1-37-on-
macos/](https://virtuallyfun.com/2016/05/24/gcc-1-37-on-macos/)

And of course using RSXNT / EMX to get GCC 1.40 targeting Windows NT

[https://virtuallyfun.com/2016/05/06/gcc-1-40-on-
windows/](https://virtuallyfun.com/2016/05/06/gcc-1-40-on-windows/)

------
ggm
I think I ran 0.97. from memory, it compiled the kind of trivial K&R C I
wrote.

------
theyregreat
To build a particular working GCC, dependencies (binutils, MPC, MPFR and GMP
(and sometimes ISL)) need to be within a particular range, preferrably within
the same time era. Also note that old compilers will often contain unpatched
security vulnerabilities.

~~~
miyuki-chan
Binutils 2.25 (released in 2016) is compatible with GCC 1.27 (released in
1988) - this is pretty amazing. As for the other libraries, they are not
needed. All GCC versions implement simple multiprecision integer arithmetics
internally, so GMP is only required by later versions of GCC for correct
handling of corner cases, especially cross compilation. GCC 1.x does not use
MPFR or any other software floating point library (and this can be problematic
for cross-compilation). ISL is a relatively new dependency (it's a library
used for some experimental loop optimizations). Needless to say, it is not
relevant for GCC 1.x. Similarly for MPC - a multiprecision complex number
library.

