About this guide - Rust Compiler Development Guide (original) (raw)

Rust Compiler Development Guide

About this guide

This guide is meant to help document how rustc – the Rust compiler – works, as well as to help new contributors get involved in rustc development.

There are several parts to this guide:

  1. Building and debugging rustc: Contains information that should be useful no matter how you are contributing, about building, debugging, profiling, etc.
  2. Contributing to Rust: Contains information that should be useful no matter how you are contributing, about procedures for contribution, using git and Github, stabilizing features, etc.
  3. Bootstrapping: Describes how the Rust compiler builds itself using previous versions, including an introduction to the bootstrap process and debugging methods.
  4. High-level Compiler Architecture: Discusses the high-level architecture of the compiler and stages of the compile process.
  5. Source Code Representation: Describes the process of taking raw source code from the user and transforming it into various forms that the compiler can work with easily.
  6. Supporting Infrastructure: Covers command-line argument conventions, compiler entry points like rustc_driver and rustc_interface, and the design and implementation of errors and lints.
  7. Analysis: Discusses the analyses that the compiler uses to check various properties of the code and inform later stages of the compile process (e.g., type checking).
  8. MIR to Binaries: How linked executable machine code is generated.
  9. Appendices at the end with useful reference information. There are a few of these with different information, including a glossary.

Constant change

Keep in mind that rustc is a real production-quality product, being worked upon continuously by a sizeable set of contributors. As such, it has its fair share of codebase churn and technical debt. In addition, many of the ideas discussed throughout this guide are idealized designs that are not fully realized yet. All this makes keeping this guide completely up to date on everything very hard!

The Guide itself is of course open-source as well, and the sources can be found at the GitHub repository. If you find any mistakes in the guide, please file an issue about it. Even better, open a PR with a correction!

If you do contribute to the guide, please see the corresponding subsection on writing documentation in this guide.

“‘All conditioned things are impermanent’ — when one sees this with wisdom, one turns away from suffering.”The Dhammapada, verse 277

Other places to find information

You might also find the following sites useful: