A History of UNIX That ClicksEpisode 0 / Prologue ── Chicken and Egg

The computing counterpart to the physics series ── this time we descend, one step at a time, into "the origin of software"

Chicken and Egg ── What Compiled Linux? The Linux kernel is compiled by gcc (or clang) running on Linux. So what about that gcc? ── The previous gcc compiled it. And the one before that? Where, exactly, did this "endlessly spinning loop" begin?

Tools you'll need: just curiosity (you don't have to read code) Watchword: the first egg was carved by hand

When you build the Linux kernel, you use a C compiler called gcc. Since gcc itself is also a program written in C, to run it you need a gcc that someone has compiled. So what compiled that gcc? ── Again, gcc. Then what made the very first gcc, in a world where not a single compiler yet existed? This is the chicken-and-egg problem. This series traces that loop backwards through time, descending into the birth of the C language, the first UNIX, and finally the "first byte."

00First, let's see the loop with our own eyes

"Compiling a compiler" makes your head spin when you write it out like this.

$ gcc -o vmlinux linux.c # gcc builds Linux $ gcc -o gcc gcc.c # and that gcc? → the previous gcc built it $ gcc -o gcc gcc.c # and the gcc before that? → an even earlier gcc… …on and on, back to earlier versions of itself (self-hosting)

An active compiler is usually written in its own language and built by its own past self. This is called self-hosting. A new gcc is made by an old gcc, which was made by an even older gcc, and so on… the loop keeps spinning round and round. Try spinning that loop in the figure below.

Figure 1: The self-hosting loop. Each generation of compiler was built by the one before it. The loop keeps spinning ── but the very first one cannot be made from within the loop.
Each compiler was built by "the previous version of itself." So what about the very first one?
The crux this time ── the loop was lifted once, from the outside

The self-hosting loop cannot start itself. It needs "the previous version of itself," yet at the very beginning there is no "previous version." So the loop must always be ignited once by something outside the loop. The word bootstrap originally comes from the physically impossible tall tale of "pulling yourself up by your own bootstraps." In the world of software, too, only the very first time is an "outside hand" needed to lift it.

01Since when had the loop been spinning? ── the first Linux (1991)

Let's rewind time. Today's Linux can be built on Linux, but the first Linux of 1991 couldn't be built on Linux, because Linux didn't exist yet. So where, then? ── The answer is on top of another Unix-like OS called MINIX. Linus Torvalds, then a student in Finland, developed on a 386 PC running MINIX. He ported GNU's gcc and bash to MINIX and compiled Linux with that gcc.

The "delivery room" of the first Linux

v0.01 (September 1991)

It couldn't even boot on its own, and without MINIX it could neither be compiled nor tested. The loop wasn't spinning yet ── it was piggybacking on another OS, MINIX.

v0.11 (December 1991)

Here, for the first time, Linux could compile Linux itself (self-hosting achieved). The moment the loop began to spin. For the roughly thirty-plus years since, that loop has kept turning.

So the "ignition" of the Linux loop was gcc on top of MINIX. The next question, then, is obvious ── what made that gcc? What made MINIX? Even once you step outside the loop, another "what made this?" is waiting. Repeating that question is the backbone of this series.

A connecting voice ── isn't it clang? Today's Linux can also be built with clang (LLVM), but that only became mainstream in the late 2010s, a latecomer; almost the entire history is the story of gcc. And clang itself is a program written in C++, so it too lives inside a self-hosting loop built by another compiler. Whether the tool is gcc or clang changes nothing about the chicken-and-egg structure.
◇ ◇ ◇

02The big picture of the staircase we're about to descend

Repeat "what made this?" and you keep walking down a staircase, step by step. This staircase is exactly the table of contents of this series. Move the slider in the figure below to go back in time, and at each step check "what made what." At the very bottom lies the answer to the chicken-and-egg riddle.

Figure 2: The staircase of tracing back. The further right you move the slider, the further into the past you descend. Each step is "what made the software of that era." At the bottom (Episode 10) is the "outside hand" that ignited the loop.
How to descend the staircase (this series' itinerary)

Today's loop (gcc/clang) → the first Linux (1991) was gcc on MINIX → gcc was ignited by an existing cc → MINIX was ACK → the first C compiler was grown from B until it self-hosted → B is a child of BCPL → the first Unix (1969) was PDP-7 assembly → that assembler was a cross-assembler on another machine + paper tape → the very first was a human entering it by hand with switches → the bottom is wired-up hardware.

03Don't mix up the two kinds of "tracing back"

Let me get ahead of things and stamp out one trap that beginners always fall into. The lineage (bloodline) story ── "Linux came from MINIX, MINIX came from BSD…" ── and the what compiled what story we've been looking at are two different things.

Two orthogonal questions

① Code lineage: did it inherit the actual source code? A family tree in which genes (code) flow, like Unix → BSD → NetBSD/FreeBSD…

② Toolchain bootstrap: what compiled what. The chicken-and-egg loop this series follows. Neither Linux nor MINIX is actually a child that inherited someone's blood; each is a clean-slate reimplementation that "behaves like Unix" (so neither appears on ①'s lineage). We'll dissect this in Episode 1.

Mix these two up and you get misunderstandings like "Linux is MINIX's child." Correctly: Linux merely borrowed MINIX as a delivery room (development environment) to grow up in; there is no blood tie. We'll do that satisfying reveal at the very start of the next episode.

The honest line ── "carved by hand" is halfway between metaphor and fact

The series' watchword, "the first egg was carved by hand," sounds like a poetic metaphor, but on the bottom step it is very nearly literal fact (Episode 9). On early computers, humans read the instruction table, worked out the machine-code numbers by hand, and entered them into memory one word at a time with toggle switches. On the other hand, claims at each step like "the first Linux was compiled by gcc on top of MINIX" are historical facts sourceable down to the dates and the people. We carefully separate these two kinds ── verifiable history and turns of phrase for understanding ── in each episode's footnotes.

Likewise, points that get prickly if spoken carelessly ── such as where to draw the line between v0.01 and v0.11 (from where do we call it "self-hosting"), or "gcc vs clang" ── are distinguished with care each time.

Practice problems (solvable with just this episode)
  1. What is "self-hosting"? In one sentence.
    Show answer
    The state in which a compiler (or other tool) is written in its own language and built by its own past self. Each new version is made by the old version.
  2. Why can't the self-hosting loop "start itself"?
    Show answer
    Because running it requires "the previous version of itself," yet at the very beginning "the previous version" does not exist. So something outside the loop (another compiler / another OS / in the end, a human hand) must ignite it once.
  3. The first Linux (v0.01) was compiled on top of what, using what?
    Show answer
    A gcc ported onto MINIX, a Unix-like OS. Linux only became able to build Linux itself (self-hosting) from v0.11 onward.
  4. What is inaccurate about the phrasing "Linux is MINIX's child"?
    Show answer
    It confuses code lineage (genes) with the development environment (the delivery room). Linux was developed on MINIX and was influenced by it, but it did not inherit MINIX's source code. Both are "clean-slate reimplementations of Unix-ness."

SummaryThe loop keeps spinning, and only the very first time was it ignited from outside

The gcc that compiles Linux was made by a previous gcc ── a compiler lives inside the self-hosting loop, written in its own language and built by its own past self. But the loop can't start on its own, because at the beginning there is no "previous self." The Linux loop was ignited in 1991 by gcc on top of MINIX (v0.01), and it stood on its own at v0.11.

Repeat "what made this?" and you walk down the staircase: gcc → existing cc → C → B → BCPL → assembly → cross-assembler → hand entry → hardware. At the bottom lie a human hand and a wired-up machine that lifted the loop just once from outside. That is the shape of this series' answer ── the first egg was carved by hand. Note that "what compiled it (the bootstrap)" and "whose genes it carries (the lineage)" are separate questions, and must not be mixed. Next time, we begin with exactly that dissection.

This document is Episode 0 (the Prologue) of "A History of UNIX That Clicks." Historical facts: Linux was begun in 1991 by the Finnish student Linus Torvalds; the early version (v0.01) could only be compiled and tested on MINIX, and Torvalds ported gcc (1.40) and bash (1.08). Linux is said to have become able to compile itself (self-hosting) at v0.11 (December 1991). Building the Linux kernel with clang/LLVM is a later option that became mainstream in the late 2010s; the historical standard compiler is gcc. "Self-hosting" and "bootstrap" (bootstrap = the connotation of lifting oneself by one's own bootstraps) are standard terms in computer science. Code lineage (the inheritance of real code, as in the BSD family) and clean-slate Unix-like reimplementation (MINIX, Linux, GNU) are separate lineages, detailed in Episode 1 of this series. Expressions like "carved by hand" are turns of phrase for understanding, but bootstrapping by hand on early computers (hand assembly, switch entry) is fact-based (Episode 9). ── To print, use your browser's "Print" and "Save as PDF" (in the print version, sliders, animations, and answers are frozen / hidden).

Printing / making a PDF: ⌘+P (on Windows, Ctrl+P). On screen, use "▶ Spin the loop" in Figure 1 to turn the self-hosting loop, and the slider in Figure 2 to trace back through time. "Show answer" opens each solution.