From 38a21e9ea611f1b3ae401642ea17daed14b3c7e9 Mon Sep 17 00:00:00 2001 From: "Ehsan M.Kermani" Date: Sun, 22 Apr 2018 16:34:32 -0700 Subject: [PATCH] expand compilation stages --- src/how-to-build-and-run.md | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/how-to-build-and-run.md b/src/how-to-build-and-run.md index 535823df..dfaf8f79 100644 --- a/src/how-to-build-and-run.md +++ b/src/how-to-build-and-run.md @@ -2,7 +2,7 @@ The compiler is built using a tool called `x.py`. You will need to have Python installed to run it. But before we get to that, if you're going to -be hacking on rustc, you'll want to tweak the configuration of the compiler. +be hacking on `rustc`, you'll want to tweak the configuration of the compiler. The default configuration is oriented towards running the compiler as a user, not a developer. @@ -55,13 +55,20 @@ compiler to compile the newer version. In particular, the newer version of the compiler, `libstd`, and other tooling may use some unstable features internally. The result is the compiling `rustc` is done in stages. -- **Stage 0:** the stage0 compiler is the current _beta_ compiler; we - download this binary from the internet. -- **Stage 1:** the code in your clone is then compiled with the stage - 0 compiler to produce the stage 1 compiler. -- **Stage 2:** the code in your clone is then compiled with the stage - 1 compiler *again* to produce the stage 2 compiler (i.e. it builds - itself). +- **Stage 0:** the stage0 compiler can be your existing (perhaps older version of) + Rust compiler, the current _beta_ compiler or you may download the binary + from the internet +- **Stage 1:** the code in your clone (for new version) + is then compiled with the stage0 + compiler to produce the stage1 compiler. + However, it was built with an older compiler (stage0), + so to optimize the stage1 compiler we go to next stage +- **Stage 2:** we rebuild our stage1 compiler with itself + to produce the stage2 compiler (i.e. it builds + itself) to have all the _latest optimizations_ +- _(Optional)_ **Stage 3**: to sanity check of our new compiler, we can build it again + with stage2 compiler which must be identical to itself, + unless something has broken For hacking, often building the stage 1 compiler is enough, but for final testing and release, the stage 2 compiler is used.