Skip to content

Commit 235c9f5

Browse files
committed
start a getting started guide
1 parent 9c5a183 commit 235c9f5

File tree

2 files changed

+224
-0
lines changed

2 files changed

+224
-0
lines changed

src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- [Part 1: Building, debugging, and contributing to Rustc](./part-1-intro.md)
88
- [About the compiler team](./compiler-team.md)
9+
- [Getting Started](./getting-started.md)
910
- [How to Build and Run the Compiler](./building/how-to-build-and-run.md)
1011
- [Suggested Workflows](./building/suggested.md)
1112
- [Bootstrapping](./building/bootstrapping.md)

src/getting-started.md

+223
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
# Getting Started
2+
3+
This documentation is _not_ intended to be comprehensive; it is meant to be a
4+
quick guide for the most useful things. For more information, [see this
5+
chapter](./building/how-to-build-and-run.md).
6+
7+
## Asking Questions
8+
9+
The compiler team (or "t-compiler") usually hangs out in Zulip [in this
10+
"stream"][z]; it will be easiest to get questions answered there.
11+
12+
[z]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler
13+
14+
**Please ask questions!** A lot of people report feeling that they are "wasting
15+
expert time", but nobody on t-compiler feels this way. Contributors are
16+
important to us.
17+
18+
Also, if you feel comfortable, prefer public topics, as this means others can
19+
see the questions and answers, and perhaps even integrate them back into this
20+
guide :)
21+
22+
### Experts
23+
24+
Not all `t-compiler` members are experts on all parts of `rustc`; it's a pretty
25+
large project. To find out who has expertise on different parts of the
26+
compiler, [consult this "experts map"][map].
27+
28+
It's not perfectly complete, though, so please also feel free to ask questions
29+
even if you can't figure out who to ping.
30+
31+
[map]: https://github.com/rust-lang/compiler-team/blob/master/content/experts/map.toml
32+
33+
### Etiquette
34+
35+
We do ask that you be mindful to include as much useful information as you can
36+
in your question, but we recognize this can be hard if you are unfamiliar with
37+
contributing to Rust.
38+
39+
Just pinging someone without providing any context can be a bit annoying and
40+
just create noise, so we ask that you be mindful of the fact that the
41+
`t-compiler` folks get a lot of pings in a day.
42+
43+
## Cloning and Building
44+
45+
The main repository is [`rust-lang/rust`][repo]. This contains the compiler,
46+
the standard library (including `core`, `alloc`, `test`, `proc_macro`, etc),
47+
and a bunch of tools (e.g. `rustdoc`, the bootstrapping infrastructure, etc).
48+
49+
[repo]: https://github.com/rust-lang/rust
50+
51+
There are also a bunch of submodules for things like LLVM, `clippy`, `miri`,
52+
etc. You don't need to clone these immediately, but the build tool will
53+
automatically clone and sync them (more later).
54+
55+
[**Take a look at the "Suggested Workflows" chapter for some helpful
56+
advice.**][suggested]
57+
58+
[suggested]: ./building/suggested.md
59+
60+
### System Requirements
61+
62+
[**See this chapter for detailed software requirements.**](./building/prerequisites.md)
63+
Most notably, you will need python 2 to run `x.py`.
64+
65+
There are no hard hardware requirements, but building the compiler is
66+
computationally expensive, so a beefier machine will help, and I wouldn't
67+
recommend building try to build on a Raspberry Pi :P
68+
69+
- x86 and ARM are both supported (TODO: confirm)
70+
- Recommended 30GB of free disk space; otherwise, you will have to keep
71+
clearing incremental caches.
72+
- Recommended >=8GB RAM
73+
- Recommended >=2 cores; more cores really helps
74+
- You will need an internet connection to build; the bootstrapping process
75+
involves updating git submodules and downloading a beta compiler. It doesn't
76+
need to be super fast, but that can help.
77+
78+
Building the compiler take more than half an hour on my moderately powerful
79+
laptop (even longer if you build LLVM).
80+
81+
### Cloning
82+
83+
You can just do a normal git clone:
84+
85+
```shell
86+
git clone https://github.com/rust-lang/rust.git
87+
```
88+
89+
You don't need to clone the submodules at this time.
90+
91+
**Pro tip**: if you contribute often, you may want to look at the git worktrees
92+
tip in [this chapter][suggested].
93+
94+
### Configuring the Compiler
95+
96+
The compiler has a configuration file which contains a ton of settings. We will
97+
provide some recommendations here that should work for most, but [check out
98+
this chapter for more info][config].
99+
100+
[config]: ./building/how-to-build-and-run.html#create-a-configtoml
101+
102+
In the top level of the repo:
103+
104+
```shell
105+
cp config.toml.example config.toml
106+
```
107+
108+
Then, edit `config.toml`. You will need to search for, uncomment, and update
109+
the following settings:
110+
111+
- `debug = true`: enables debug symbols and `debug!` logging, takes a bit longer to compile.
112+
- `incremental = true`: enables incremental compilation of the compiler itself.
113+
This is turned off by default because it's technically unsound. Sometimes
114+
this will cause weird crashes, but it can really speed things up.
115+
- `llvm-config`: enable building with system LLVM. [See this chapter][sysllvm]
116+
for more info. This avoids having to build LLVM, which takes forever.
117+
118+
[sysllvm]: ./building/suggested.html#building-with-system-llvm
119+
120+
### `./x.py` Intro
121+
122+
`rustc` is a bootstrapping compiler because it is written in Rust. Where do you
123+
get do you get the original compiler from? We use the current `beta` compiler
124+
to build the compiler. Then, we use that compiler to build itself. Thus,
125+
`rustc` has a 2-stage build.
126+
127+
We have a special tool `./x.py` that drives this process. It is used for
128+
compiling the compiler, the standard libraries, and `rustdoc`. It is also used
129+
for driving CI and building the final release artifacts.
130+
131+
### Building and Testing `rustc`
132+
133+
For most contributions, you only need to build stage 1, which saves a lot of time.
134+
After updating `config.toml`, as mentioned above, you can use `./x.py`:
135+
136+
```shell
137+
# Build the compiler (stage 1)
138+
./x.py build --stage 1
139+
```
140+
141+
This will take a while, especially the first time. Be wary of accidentally
142+
touching or formatting the compiler, as `./x.py` will try to recompile it.
143+
144+
To run the compiler's UI test (the bulk of the test suite):
145+
146+
```
147+
# UI tests
148+
./x.py test --stage 1 src/test/ui
149+
```
150+
151+
This will build the compiler first, if needed.
152+
153+
This will be enough for most people. Notably, though, it mostly tests the
154+
compiler frontend, not codegen or debug info. You can read more about the
155+
different test suites [in this chapter][testing].
156+
157+
[testing]: https://rustc-dev-guide.rust-lang.org/tests/intro.html
158+
159+
If you only want to check that the compiler builds (without actually building
160+
it) you can run the following:
161+
162+
```shell
163+
./x.py check
164+
```
165+
166+
To format the code:
167+
168+
```shell
169+
# Actually format
170+
./x.py fmt
171+
172+
# Just check formatting, exit with error
173+
./x.py fmt --check
174+
```
175+
176+
You can use `RUSTC_LOG=XXX` to get debug logging. [Read more here][logging].
177+
178+
[logging]: ./compiler-debugging.html#getting-logging-output
179+
180+
### Building and Testing `std`/`core`/`alloc`/`test`/`proc_macro`/etc.
181+
182+
TODO
183+
184+
### Building and Testing `rustdoc`
185+
186+
TODO
187+
188+
### Contributing code to other Rust projects
189+
190+
TODO: talk about things like miri, clippy, chalk, etc
191+
192+
## Contributor Procedures
193+
194+
There are some official procedures to know about. This is a tour of the
195+
highlights, but there are a lot more details, which we will link to below.
196+
197+
### Bug Fixes
198+
199+
TODO: talk about bors, highfive
200+
201+
### New Features
202+
203+
TODO: talk about RFCs, stabilization
204+
205+
### Breaking Changes
206+
207+
TODO: talk about crater, FCP, etc
208+
209+
### Major Changes
210+
211+
TODO: talk about MCP
212+
213+
### Performance
214+
215+
TODO: Talk about perf runs
216+
217+
## Other Resources
218+
219+
- This guide: talks about how `rustc` works
220+
- [The t-compiler zulip][z]
221+
- [The compiler's documentation (rustdocs)](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/)
222+
223+
TODO: am I missing any?

0 commit comments

Comments
 (0)