-
Notifications
You must be signed in to change notification settings - Fork 520
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
Explain stages (take N) #843
Conversation
More of the discussion that came up with this (warning: lots and lots of backlog): https://rust-lang.zulipchat.com/#narrow/stream/196385-t-compiler.2Fwg-rustc-dev-guide/topic/meeting.2008.2E04.2E2020/near/205939628 |
|
||
<!-- TODO: label each of the cells with the name of the directory in `build` it corresponds to --> | ||
|
||
![stages](./stages.png) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RDambrosio016 mentioned that I should probably explain what stage 3 is and that it's not really useful except for verifying reproducible builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@jyn514 the diagram says that |
It's worded poorly in the diagram - |
Or in other words, |
I like this ❤️ |
Oh, that's what you mean. I am just wondering why it seems so inconsistent here (rows vs columns), when it doesn't feel so inconsistent when I use it. |
The way I think about it is that Also, should "tools" (clippy, miri) be included in the diagram? The compiler-dependent tools would be below rustc. (The other tools are not subject to staging I think.) |
That corresponds to the columns/rows view, no? Where tested corresponds to 'run-stage'?
Hmm ... I'd put it in the same cell as But I don't think your description is accurate: when you say
Good idea, I'll do that. They should go in the same cell as |
(except rustdoc because rustdoc is special and it would just be even more confusing) |
I posted on zulip too, but just so it's easy to find, here is the tex of the diagram: https://gist.github.com/mark-i-m/e0c885f7b585f02232962b5be0d457f8 |
...OH. |
I think I have a consistent picture that never uses the "row view" so do I don't think you need that view. With there being a "test" in between "std" and "rustc" (or in the same cell as "std"), then |
I had a whole speech about how I thought my viewpoint was right, but after thinking about it now I'm not sure any more ... the way you see builds is that I guess that implies the current system for @eddyb what do you think about this? |
and to clear up some confusion on my end: when I |
I find that question confusing because everything runs stage0/bin/rustc. But it finishes up by buillding the standard library with stage1/bin/rustc |
Ok yes that was my question, thanks. So that's consistent with the model @RalfJung has. |
I think there's probably multiple "right" viewpoints that explain the same behavior in different ways. I just wonder which one is "best" in the sense of being easiest to teach and learn. |
I did not really understand it until I looked at the diagram presented here, in spite of reading the description in rustc-dev-guide several times, and I have repeatedly tried to run The words around it are mostly secondary, imo. |
Maybe it would be helpful to document both models of staging? Mention that the guide and various other places use the ' |
@jyn514 The diagram is great. However, as I understand from the latest changes, the wording needs to be amended:
If $X is omitted, this implies $X = everything in row N. |
Yes to all points except
Right now tools are built as well, I want to change that though: rust-lang/compiler-team#351 |
It would be nice to clarify what happens on In my head I can imagine representing this with another dimension to the diagram but that might not look so nice in practice. |
I would need help with cross-compiling - maybe that could be a follow-up PR? Definitely good information to have, though. |
I put these in prose instead, since they always match up with the I also added a section for @RalfJung's view of 'stage' as 'run
This was added in #851, I didn't discuss it more here. |
Can't change this in the diagram until I find the sources.
Just some feedback on the overall direction here, I feel like this makes it more complicated and confusing. Adding multiple new terminology (run-stage and build-stage) that haven't been used before seems to add layers of complexity that I don't really understand. I also think it would not be a good idea to try to introduce multiple mental models. I appreciate trying to improve the documentation, and am thankful you are trying to tackle it. I think the wall of text on bootstrapping is too much, but this seems to add more content, instead of remove it. I guess I am a bit uncertain why people are so confused by the topic, as it isn't that complicated. My personal confusion in the past mostly stemmed around feeling like the numbering seemed off-by-one (like, the "stage 0" compiler created a "stage0-rustc" directory, which seemed confusing because I expected it to create stage N+1). But at the time there wasn't much documentation, and this was just me fumbling around. Once I learned "stage" was more of a "step in a process", and the relationship between the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, it looks like it's off to a good start, but I still find some pieces confusing. I think they just need a bit more explanation to give more context to people who are newer to rustc (like me!). The part that I feel still needs the most explanation is the distinction between run-stage
and build-stage
.
I left a bunch of comments; I hope they're not overwhelming! Some of them are just small typographical things though.
Let me know if you need more clarification about my comments! And also, thank you for putting in the work to explain this better in the guide!
Does `--stage 1` mean to _build_ the stage 1 artifacts or to _run_ them? | ||
In fact, it means both! | ||
|
||
<!-- TODO: label each of the cells with the name of the directory in `build` it corresponds to --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this TODO still valid?
Rows are things that can be used together to build a program. | ||
\\ | ||
|
||
\noindent \verb|./x.py build --stage N| builds programs in \emph{column} \verb|N| (except rustdoc - it builds rustdoc from column \verb|N - 1|).\\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To get a proper en dash:
\noindent \verb|./x.py build --stage N| builds programs in \emph{column} \verb|N| (except rustdoc - it builds rustdoc from column \verb|N - 1|).\\ | |
\noindent \verb|./x.py build --stage N| builds programs in \emph{column} \verb|N| (except rustdoc -- it builds rustdoc from column \verb|N - 1|).\\ |
- `rustfmt` | ||
- `clippy` | ||
- `miri` | ||
- compiler plugins |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly is meant by "compiler plugins"? When I hear "compiler plugins" I think of procedural macros, but I don't think that's what's meant here.
### What are `run-stage` and `build-stage`? | ||
|
||
`run-stage` means that this deals with _running_ the compiler, | ||
so `--stage N` refers to the artifacts in `build/stageN`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as below: I think it's clearer if you delineate what is literal text and what is filled in with some value.
so `--stage N` refers to the artifacts in `build/stageN`. | |
so `--stage N` refers to _running_ the artifacts in `build/<toolchain>/stageN`. |
so `--stage N` refers to the artifacts in `build/stageN`. | ||
|
||
`build-stage` means that this deals with _building_ the compiler, | ||
and it refers to `build/stageN-component`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's clearer if you delineate what is literal text and what is filled in with some value.
and it refers to `build/stageN-component`. | |
and it refers to `build/<toolchain>/stageN-<component>`. |
- `test` | ||
- `proc_macro` | ||
|
||
### What are `run-stage` and `build-stage`? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't feel like I fully understand what the distinction between these is.
\noindent \verb|build| excludes \verb|rustc| by default. | ||
|
||
Use \verb|build --stage N src/rustc| to build the \verb|rustc| in \emph{column} | ||
\verb|N|. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This confuses me. It sounds like it means that ./x.py build
doesn't build the compiler, but that doesn't seem right.
\node[text width=5in] at (2.5, -6) { | ||
\noindent \verb|build| excludes \verb|rustc| by default. | ||
|
||
Use \verb|build --stage N src/rustc| to build the \verb|rustc| in \emph{column} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use \verb|build --stage N src/rustc| to build the \verb|rustc| in \emph{column} | |
Use \verb|build --stage N compiler/rustc| to build the \verb|rustc| in \emph{column} |
|
||
### Why have `build-stage` at all? | ||
|
||
`stage0/bin/rustc` can't open an rlib from stage1-* or vice-versa. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`stage0/bin/rustc` can't open an rlib from stage1-* or vice-versa. | |
`stage0/bin/rustc` can't open an rlib (a Rust static library archive) from `stage1-*` or vice-versa. |
@@ -276,6 +346,8 @@ artifacts respectively. | |||
Additionally, the `RUSTFLAGS_STAGE_NOT_0` variable, as its name suggests, pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not from this PR, but I figure we might as well fix it now!
Additionally, the `RUSTFLAGS_STAGE_NOT_0` variable, as its name suggests, pass | |
Additionally, the `RUSTFLAGS_STAGE_NOT_0` variable, as its name suggests, passes |
Closing this in favor of #857. |
Successor to #807 that doesn't try to change what 'stage' means. Instead, it accepts that there are two meanings and explains both, as well as the context in which they are used.
Before reading the text, I strongly recommend taking a look at the diagram added (thanks to @mark-i-m for writing it up!).
I would like to do the following before this merges:
RenamedDone.link-stage
tobuild-stage
in the diagram. While it's true that those stages are linked together, 'build' more accurately describes how x.py refers to them. I'm willing to be convinced the opposite direction for this, in which casebuild-stage
should be renamed tolink-stage
in the text.build/*/stage*
corresponding to each cell of the diagram - I haven't done this, but it's discussed in detail in 'Understanding Stages of Bootstrap', so maybe it's not necessary?I don't have access to the TeX sources for the diagram, so both of the above are waiting on @mark-i-m (no pressure or anything :P).Mark got me the .tex file (thank you!)I'm also interested in cleaning up the existing 'Stage of Boostrap' section, but I'm not exactly sure how best to do that ... there's definitely good information there, it's just hard to find in the wall of text.
Comments welcome!
cc @eddyb @Mark-Simulacrum