What is Rust written in?
Rust is self-hosting: the Rust compiler (rustc) is written in Rust. The first version of rustc was written in OCaml; Rust became self-hosting in 2011. mrustc is an alternative Rust compiler written in C++ that can bootstrap rustc from source.
Quick Facts
- Short answer
- rustc is written in Rust
- Original compiler
- OCaml
- Backend
- LLVM
- Bootstrap status
- Self-hosting since 2011
Details
Rustc, the official Rust compiler, is written in Rust, making Rust self-hosting. Self-hosting means the compiler can compile the source code of its own compiler.
Rust was not self-hosting from day one. Early Rust used a compiler written in OCaml, then moved to rustc written in Rust once the language and compiler were mature enough.
Rust implementation layers
| Layer | Written in | Role |
|---|---|---|
| rustc frontend and compiler driver | Rust | Parses, type-checks, and drives compilation |
| Historical compiler | OCaml | Original Rust compiler before self-hosting |
| LLVM backend | C++ | Optimization and machine-code generation |
| mrustc | C++ | Alternative compiler relevant to bootstrap chains |
The bootstrap chain normally uses a previous rustc snapshot to build the next compiler version. The dataset records both Rust's self-hosting chain and the historical OCaml origin.
Explore in the Graph
See implementation and influence relationships interactively.
Open Interactive Graph →