Understanding how the Rust compiler is built

For rustc specifically the bootstrap chain involves OCaml. The first Rust compiler was written in OCaml (and in fact it is one of the languages that influenced Rust). Only a couple of years later did a Rust compiler get written in rust itself. Both existed in parallel for a bit before the OCaml based compiler got deleted. Rustc back then was a lot buggier than it is right now. In fact I read somewhere that it was buggy enough that the bootstrap compiler would get updated every couple of days or even more frequent (so between the first self-hosting compiler and rustc 1.0 there were hundreds if not thousands of steps), only later on did these updates slow down to bootstrapping from the previous release. This is also a part of why mrustc is a big deal. It is basically impossible to reproduce the original bootstrap chain, so an alternative rust compiler with an independent bootstrap chain (this time from C++) was the only way to know for certain that there was no backdoor introduced at some point.

8 Likes