Stream: t-compiler

Topic: compiler stages

Nikita Popov (Oct 26 2018 at 11:14, on Zulip):

I'm a bit confused about what exactly the stage0 and stage1 compilers are. I thought stage0 is the previous beta compiler and stage1 is the checkout built with the stage0 compiler. However, changing files in the checkout also triggers a (partial) rebuild of the stage0 compiler. Why is that?

oli (Oct 26 2018 at 11:23, on Zulip):

stage0 is only the compiler, there are no standard library binaries included. So the first thing the stage0 compiler does is build its libstd

oli (Oct 26 2018 at 11:24, on Zulip):

if you modify libstd/libcore or similar, then stage0 will rebuild that, causing a full stage 1 rebuild

oli (Oct 26 2018 at 11:24, on Zulip):

you can prevent this by passing --keep-stage 0 to your command line

Nikita Popov (Oct 26 2018 at 11:32, on Zulip):

So if I currently have a stage0 and stage1 compiler (default config), I run touch src/librustc/ && ./ build --stage 1. This first skips building stage0 std and test and then does:
Building stage0 compiler artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
Compiling rustc v0.0.0 (/home/nikic/rust/src/librustc)

Nikita Popov (Oct 26 2018 at 11:33, on Zulip):

It does not rebuild the stage0 libstd, but does seem to rebuild the stage0 compiler (or at least the parts that were changed)

oli (Oct 26 2018 at 11:46, on Zulip):

oh, well, not quite. It's building the compiler artifacts with the stage0 compiler (because it doesn't have a stage1 compiler yet)

oli (Oct 26 2018 at 11:46, on Zulip):

the compiler that is being built is the stage 1 compiler

Nikita Popov (Oct 26 2018 at 12:05, on Zulip):

Ah, so I guess I should be interpreting "building stageN artifacts" not as "building artifacts for use in stageN" but rather "building artifacts using stageN for use in stageN+1", right?

nagisa (Oct 26 2018 at 13:18, on Zulip):

That’s how I understand it, yes.

Last update: Jul 14 2020 at 12:20UTC