-
Notifications
You must be signed in to change notification settings - Fork 546
Add quickstart for how to build and run the compiler #1951
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Quickstart | ||
|
||
This is a quickstart guide about getting the compiler running. For more information in the individual steps, | ||
see the other pages in this chapter. | ||
|
||
First, clone the repository: | ||
|
||
```sh | ||
git clone https://github.com/rust-lang/rust.git | ||
cd rust | ||
``` | ||
|
||
When building the compiler, we don't use `cargo` directly, instead we use a wrapper called "x". | ||
It is invoked with `./x`. | ||
|
||
We need to create a configuration for the build. Use `./x setup` to create a good default. | ||
|
||
```sh | ||
./x setup | ||
``` | ||
|
||
Then, we can build the compiler. Use `./x build` to build the compiler, standard library and a few tools. | ||
You can also `./x check` to just check it. | ||
All these commands can take specific components/paths as arguments, for example `./x check compiler` to just check the compiler. | ||
|
||
```sh | ||
./x build | ||
``` | ||
|
||
> When doing a change to the compiler that does not affect the way it compiles the standard library | ||
(so for example, a change to an error message), use `--keep-stage-std 1` to avoid recompiling it. | ||
|
||
After building the compiler and standard library, you now have a working compiler toolchain. | ||
You can use it with rustup by linking it. | ||
|
||
```sh | ||
rustup toolchain link stage1 build/host/stage1 | ||
``` | ||
|
||
Now you have a toolchain called `stage1` linked to your build. You can use it to test the compiler. | ||
|
||
```sh | ||
rustc +stage1 testfile.rs | ||
``` | ||
|
||
After doing a change, you can run the compiler test suite with `./x test`. | ||
|
||
`./x test` runs the full test suite, which is slow and rarely what you want. | ||
Usually, `./x test tests/ui` is what you want after a comiler change, | ||
testing all [UI tests](../tests/ui.md) that invoke the compiler on a specific test file and check the output. | ||
|
||
```sh | ||
./x test tests/ui | ||
``` | ||
|
||
Use `--bless` if you've made a change and want to update the `.stderr` files with the new output. | ||
|
||
> `./x suggest` can also be helpful for suggesting which tests to run after a change. | ||
|
||
Congrats, you are now ready to make a change to the compiler! If you have more questions, | ||
Noratrieb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[the full chapter](./how-to-build-and-run.md) might contain the answers, and if it doesn't, | ||
feel free to ask for help on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp). | ||
|
||
If you use VSCode, `./x setup` will ask you if you want to set up the config. For other editors, check out [suggested workflows](./suggested.md). |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.