-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x.py's naming of stages is confusing #59864
Comments
FWIW I also found this confusing for a while, and would support this chnage.
… On Apr 10, 2019, at 7:23 PM, Nicholas Nethercote ***@***.***> wrote:
Rust has the standard multi-stage structure that all bootstrapping compilers have.
A newcomer who knows about compiler stages will be confident with this, until they run a command like ./x.py build --stage 1 and get output like this:
Building stage0 std artifacts
...
Copying stage0 std from stage0
Building stage0 test artifacts
...
Copying stage0 test from stage0
Building stage0 compiler artifacts
...
Copying stage0 rustc from stage0
Building stage0 codegen artifacts
...
Assembling stage1 compiler
Building stage1 std artifacts
...
Copying stage1 std from stage1
Building stage1 test artifacts
...
Copying stage1 test from stage1
Building stage1 compiler artifacts
...
Copying stage1 rustc from stage1
Building stage1 codegen artifacts
...
Building rustdoc for stage1
...
For a newcomer, this is completely bizarre.
Why is it building stage 0? Isn't stage 0 the compiler you download?
Why is it building two stages? Shouldn't it only build one stage?
The key to understanding this is that x.py uses a surprising naming convention:
A "stage N artifact" is an artifact that is produced by the stage N compiler.
The "stage (N+1) compiler" is assembled from "stage N artifacts".
A --stage N flag means build with stage N.
Somebody had to explain this to me when I started working on Rust. I have since had to explain it to multiple newcomers. Even though I understand it now, I still find it very confusing, and I have to think carefully about it all.
Here's a naming convention that makes more sense to me:
A "stage N artifact" is an artifact that is produced by the stage (N-1) compiler.
The "stage N compiler" is assembled from "stage N artifacts".
A --stage N flag means build stage N, using stage (N-1).
That way, a command like ./x.py build --stage 1 would produce output like this:
Building stage1 std artifacts
...
Copying stage1 std from stage1
Building stage1 test artifacts
...
Copying stage1 test from stage1
Building stage1 compiler artifacts
...
Copying stage1 rustc from stage1
Building stage1 codegen artifacts
...
Assembling stage1 compiler
Is there any appetite for this change? I realize it would be invasive and people would have to update their aliases, build scripts, etc. But it might be worthwhile to avoid the ongoing confusion to both newcomers and experienced contributors. Deprecating the word "stage" in favour of "phase" could help with the transition.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@ehuss that diagram is excellent! |
cc @Mark-Simulacrum @alexcrichton -- related to the discussion we had at all-hands. |
My plan is to put in sometime this weekend to figure out and propose PRs for the changes discussed at the all hands (which should, to an extent, remove this issue by making dealing with --stage largely unnecessary). We may separately want to land a patch that changes stage "naming" though. |
I basically have to re-figure this out any time I'm doing anything complex with rustc, and yeah, we should change the naming here. A key issue here is that the rust compiler is actually a thin wrapper around underlying libraries, which are shipped with rust like the stdlib is. So which stage is which differs based on whether you care about the stdlib or the compiler. Kind of. I've complained about this before and generally seen agreement that this needs fixing but not as many good solutions |
@nnethercote I think your explanation and @ehuss diagram are perfect for rustc-guides 😄. I also would like to see this change happen, meanwhile can we document this on Rustc? are you comfortable if your explanation and diagrams are reused for rustc-guides?. |
Friday was the first time I compiled rust and it was pretty confusing for me too. I really like the diagram. |
At minimum, we should move that content to the rustc-guide, yes. I am agnostic about the names. I'm wary that all names will be confusing unless there is a picture, and if there is a picture, any name may be fine. |
The current plan (discussed and mentioned at all hands) is to work towards not needing to say "--stage" unless you're hacking on rustbuild itself or doing something odd; I'm not sure how quickly we can make that happen, but hopefully quite soon. |
@Mark-Simulacrum Does that apply to |
Yes, keep-stage as well -- you can see some notes here: https://paper.dropbox.com/doc/Rustbuild-All-Hands-2019--AbYzEwK9y9KN~OKiOg2bMnWrAQ-MLKsxxj1SXORp4Qg8aGbQ |
Absolutely, please use the above words any way you like. |
FWIW I suffered the exact same confusion until @eddyb explained the rustc stage naming to me. |
Same for me. Does this means that if I only need to build the sources, I only need to pass |
@robinmoussu The best way to get the correct behavior is to run tests, IME. |
I think overall the worst UX aspect is that And in general So making Oh and we need to get rid of fulldeps tests and similar things: Right now I'm forced to use this command: |
Thanks. And I agree this mess need to be clean-up. I hope someone will someday do the work. |
Would it also help if the sysroot directories were named Then some intuition there is that |
To make things even more confusing, this is not actually always true... |
@oli-obk pointed out that stage 0 Miri is being built by the bootstrap compiler, but against the stage 0 compiler artifacts (i.e., it is linked with those). 🤯 |
I have a proposal for explaining this better in rust-lang/rustc-dev-guide#843. Please let me know if that helps at all and if not, what I could do to make it better :) |
I have not gotten a lot of feedback about rust-lang/rustc-dev-guide#857 except from new contributors. Do you think it explains this well enough to close the issue, or are there still parts of bootstrapping that are confusing? I'm happy to add more documentation if you think it will help. (You can see the rendered docs at https://rustc-dev-guide.rust-lang.org/building/bootstrapping.html.) |
@jyn514 I think what we really need is a set of scenarios like:
There's some of this in the first chapter, but there really should be more. |
But the docs about what the stages themselves mean are good! That and |
I have a proposal for making this simpler in https://jyn.dev/2023/01/12/Bootstrapping-Rust-in-2023.html. |
btw here is an updated progress message from x.py:
hopefully |
I wonder if this direction may help further?
Interesting to me that rust-analyzer-proc-macro-srv is same-stage but most tools are cross-stage |
Fix cargo staging for run-make tests Follow-up to rust-lang#130642 (comment) to make sure that when ``` $ COMPILETEST_FORCE_STAGE0=1 ./x test run-make --stage 0 ``` is used, bootstrap cargo is used in order to avoid building stage 1 rustc. Note that run-make tests are usually not written with `--stage 0` in mind and some tests may rely on stage1 rustc (nightly) behavior, and it is expected that some tests will fail under this invocation. This PR also fixes `tool::Cargo` staging in compiletest when preparing for `run-make` test mode, by chopping off a stage from the `compiler` passed to `tool::Cargo` such that when the user invokes with stage `N` ``` ./x test run-make --stage N ``` the `run-make` test suite will be tested against the cargo built by stage `N` compiler. Let's take `N=1`, i.e. `--stage 1`, without chopping off a stage, previously `./x test run-make --stage 1` will cause stage 1 rustc + std to be built, then stage 2 rustc, and cargo will be produced by the stage 2 rustc, which is clearly not what we want. By chopping off a stage, it means that cargo will be produced by the stage 1 rustc. cc rust-lang#119946, rust-lang#59864. See discussions regarding the tool staging at https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/.E2.9C.94.20stage1.20run-make.20tests.20now.20need.20stage2.20rustc.20built.20for.20c.2E.2E.2E.
Rust has the standard multi-stage structure that all bootstrapping compilers have.
A newcomer who knows about compiler stages will be confident with this, until they run a command like
./x.py build --stage 1
and get output like this:For a newcomer, this is completely bizarre.
The key to understanding this is that
x.py
uses a surprising naming convention:--stage N
flag means build with stage N.Somebody had to explain this to me when I started working on Rust. I have since had to explain it to multiple newcomers. Even though I understand it now, I still find it very confusing, and I have to think carefully about it all.
Here's a naming convention that makes more sense to me:
--stage N
flag means build stage N, using stage (N-1).That way, a command like
./x.py build --stage 1
would produce output like this:Is there any appetite for this change? I realize it would be invasive and people would have to update their aliases, build scripts, etc. But it might be worthwhile to avoid the ongoing confusion to both newcomers and experienced contributors. Deprecating the word "stage" in favour of "phase" could help with the transition.
The text was updated successfully, but these errors were encountered: