-
Notifications
You must be signed in to change notification settings - Fork 549
Getting started guide #731
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
Changes from 1 commit
bc8d658
3af22dc
cb59548
4011af0
bde0b6b
ddef3e2
2301cd5
10f16cf
a9b72eb
f4a55ad
3e6a8b8
8ad947b
62e7f0e
8d742b2
c37d6bc
c645df3
9417073
7694270
922cfa6
a0b4bcf
6258881
7dc886d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,6 +163,20 @@ things up. | |
|
||
### Building and Testing `rustc` | ||
|
||
Here is a summary of the different commands for reference, but you probably | ||
should still read the rest of the section: | ||
|
||
| Command | When to use it | | ||
| --- | --- | | ||
| `x.py check` | Quick check to see if things compile; rust-analyzer can run this automatically for you | | ||
| `x.py build --stage 1` | Build just the 1st stage of the compiler; this is faster than building stage 2 and usually good enough | | ||
| `x.py build --stage 1 --keep-stage 1` | Build the 1st stage of the compiler and skips rebuilding the library; this is useful after you've done an ordinary stage1 build to skip compilation time, but it can cause weird problems. (Just do a regular build to resolve.) | | ||
| `x.py test --stage 1` | Run the test suite using the stage1 compiler (first build) | | ||
| `x.py test --stage 1 --keep-stage 1` | Run the test suite using the stage1 compiler (subsequent builds) | | ||
| `x.py test --stage 1 --bless [--keep-stage 1]` | Run the test suite using the stage1 compiler _and_ update expected test output. | | ||
| `x.py build` | Do a full 2-stage build. You almost never want to do this. | | ||
| `x.py test` | Do a full 2-stage build and run all tests. You almost never want to do this. | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only time I've had this come up was for rust-lang/rust#68692 (comment), where something failed in stage 2 libtest and nowhere else. That was definitely an edge case though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For me there were some tests that failed with stage 2 in libstd for some reason... iirc, they had to do with networking and locking... |
||
|
||
To do a full 2-stage build of the whole compiler, you should run this (after | ||
updating `config.toml` as mentioned above): | ||
|
||
|
@@ -206,14 +220,21 @@ different test suites [in this chapter][testing]. | |
[uitests]: ./tests/adding.html#ui | ||
[testing]: https://rustc-dev-guide.rust-lang.org/tests/intro.html | ||
|
||
``` | ||
```sh | ||
# First build | ||
./x.py test --stage 1 src/test/ui | ||
|
||
# Subsequent builds | ||
./x.py test --stage 1 src/test/ui --keep-stage 1 | ||
``` | ||
|
||
If your changes impact test output, you can use `--bless` to automatically | ||
update the `.stderr` files of the affected tests: | ||
|
||
```sh | ||
./x.py test --stage 1 src/test/ui --keep-stage 1 --bless | ||
``` | ||
|
||
While working on the compiler, it can be helpful to see if the code just | ||
compiles (similar to `cargo check`) without actually building it. You can do | ||
this with: | ||
|
@@ -223,7 +244,9 @@ this with: | |
``` | ||
|
||
This command is really fast (relative to the other commands). It usually | ||
completes in a couple of minutes on my laptop. | ||
completes in a couple of minutes on my laptop. **A common workflow when working | ||
on the compiler is to make changes and repeatedly check with `./x.py check`. | ||
Then, run the tests as shown above when you think things should work.** | ||
|
||
Finally, the CI ensures that the codebase is using consistent style. To format | ||
the code: | ||
|
@@ -447,10 +470,14 @@ relatively lightweight mechanism for getting feedback on large changes to the | |
compiler (as opposed to a full RFC or a design meeting with the team). | ||
|
||
Example of things that might require MCPs include major refactorings, changes | ||
to important types, or important changes to how the compiler does something. | ||
to important types, or important changes to how the compiler does something, or | ||
smaller user-facing changes. | ||
|
||
**When in doubt, ask on [zulip][z]. It would be a shame to put a lot of work | ||
into a PR that ends up not getting merged!** | ||
into a PR that ends up not getting merged!** [See this document][mcpinfo] for | ||
more info on MCPs. | ||
|
||
[mcpinfo]: https://forge.rust-lang.org/compiler/mcp.html | ||
|
||
mark-i-m marked this conversation as resolved.
Show resolved
Hide resolved
|
||
### Performance | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.