-
Notifications
You must be signed in to change notification settings - Fork 574
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
…ommands
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -66,7 +66,6 @@ There are no hard hardware requirements, but building the compiler is | |||||||||||||
| computationally expensive, so a beefier machine will help, and I wouldn't | ||||||||||||||
| recommend trying to build on a Raspberry Pi :P | ||||||||||||||
|
|
||||||||||||||
| - x86 and ARM are both supported (TODO: confirm) | ||||||||||||||
| - Recommended >=30GB of free disk space; otherwise, you will have to keep | ||||||||||||||
| clearing incremental caches. More space is better, the compiler is a bit of a | ||||||||||||||
| hog; it's a problem we are aware of. | ||||||||||||||
|
|
@@ -125,34 +124,60 @@ In the top level of the repo: | |||||||||||||
| cp config.toml.example config.toml | ||||||||||||||
| ``` | ||||||||||||||
|
|
||||||||||||||
| Then, edit `config.toml`. You will need to search for, uncomment, and update | ||||||||||||||
| Then, edit `config.toml`. You may want to search for, uncomment, and update | ||||||||||||||
| the following settings: | ||||||||||||||
|
|
||||||||||||||
| - `debug = true`: enables debug symbols and `debug!` logging, takes a bit longer to compile. | ||||||||||||||
| - `incremental = true`: enables incremental compilation of the compiler itself, | ||||||||||||||
| which can significantly speed things up. This is turned off by default | ||||||||||||||
| because it's technically unsound; sometimes this will cause weird crashes. | ||||||||||||||
| Also, it can consume a lot of disk space. | ||||||||||||||
| because it's technically unsound; sometimes it will cause weird crashes. | ||||||||||||||
| Also, it can consume a lot of disk space. This has the same effect as the | ||||||||||||||
| `-i` or `--incremental` flags. | ||||||||||||||
| - `llvm-config`: enables building with system LLVM. [See this chapter][sysllvm] | ||||||||||||||
| for more info. This avoids building LLVM, which can take a while. | ||||||||||||||
mark-i-m marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
|
|
||||||||||||||
| [sysllvm]: ./building/suggested.html#building-with-system-llvm | ||||||||||||||
|
|
||||||||||||||
| ### `./x.py` Intro | ||||||||||||||
|
|
||||||||||||||
| `rustc` is a bootstrapping compiler because it is written in Rust. Where do you | ||||||||||||||
| `rustc` is a _bootstrapping_ compiler because it is written in Rust. Where do you | ||||||||||||||
mark-i-m marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
| get the original compiler from? We use the current beta compiler | ||||||||||||||
| to build the compiler. Then, we use that compiler to build itself. Thus, | ||||||||||||||
mark-i-m marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
| `rustc` has a 2-stage build. | ||||||||||||||
| `rustc` has a 2-stage build. You can read more about bootstrapping | ||||||||||||||
| [here][boot], but you don't need more to contribute. | ||||||||||||||
mark-i-m marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
|
|
||||||||||||||
| [boot]: ./building/bootstrapping.md | ||||||||||||||
|
|
||||||||||||||
| We have a special tool `./x.py` that drives this process. It is used for | ||||||||||||||
| compiling the compiler, the standard libraries, and `rustdoc`. It is also used | ||||||||||||||
mark-i-m marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||
| compiling the compiler, the standard libraries, and `rustdoc`. It is also used | |
| compiling the compiler, the standard library, and `rustdoc`. It is also used |
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.
Mostly I said libraries because there is std, core, alloc, proc_macro, test, etc... not sure what else to call them.
mark-i-m marked this conversation as resolved.
Show resolved
Hide resolved
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 feel like if we think this is what people should do most of the time, we should suggest it first, maybe?
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.
Hmm I also think it'd be good to integrate the x.py check.
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 that my own workflow at this point is basically:
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
x.py checkwhile editing; try whenever possible to structure my changes into things that the compiler can fully enforce, and make commits as I go. This also helps with reviewing. - Run
x.py buildandx.py test --blesswhen necessary.
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.
Anyway I don't know, I'm not sure what specific suggestion I have, but I think we could convey this information better. I was toying with the idea of a flowchart (see this mermaid live editor example) but I think it's maybe not that effective.
I guess I feel like it'd be nice to present the information in a "summary form", maybe something like this instead?
| 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 |
x.py test --stage 1 --bless |
... |
...and then give more details below?
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.
So, I definitely agree that I think we should make the "default" commands the ones that most people need rather than what release does (e.g. ./x.py build would do a stage-1 incremental build), but it also seems odd to have the default command be technically unsound...
I'm not really sure what to make of this situation...
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.
Oh, also, I forgot to mention --bless...
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 vote for the most common commands first, with a disclaimer that they may not work and you should ask on Zulip.
Since it’s a getting started guide, I think the command that beginners will use more should be at the top.
Maybe mention that after a major rust release, you should run the sound command since now the older part was compiled with a different compiler? At least, I think I needed to do that after 1.44
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.
Maybe say not to worry about using bless often since you can just compare the git diff later? At first I thought it was better to edit stderr manually, until I realized I could just diff later
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 added Niko's table to the top of the section.
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 am unsure that the tests take all available CPU cores to run, and in my experience I was under the impression that the tests ran faster if I passed the --jobs flag. I am sure of nothing though, I should probably dive into the sources for the bootstrap to find out.
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.
TMK, compiletest will use all available CPUs and run as many parallel tasks as possible. I might be wrong though. I just remember that on my laptop compiletest will max out CPU.
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.
the tests ran faster if I passed the --jobs flag
This depends on what you have codegen-units set to in config.toml. I have it set to codegen-units = 0 but I think the default might be 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.
I think we should consider having a (minimal)
config.toml.devor something that has the recommended settings.That said, I do not recommend
debug = true-- but maybe my advice is out of date. I do recommenddebug-assertions=true, as well asccachefor LLVM, though I've never tried using the system LLVM, that may be better indeed.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.
Without
debug = true, you won't see anydebug!logging. @eddyb recommendeddebug = trueanddebuginfo = 1a while back, maybe we could change debuginfo to default to 1 instead of 2 whendebugis set?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've started this hackmd to collect various suggestions that have come up: https://hackmd.io/@ux-jKBcgRTSHsH042VF3BA/rkXEozKTU/edit