3
3
<!-- toc -->
4
4
5
5
Now that we have [ seen what the compiler does] [ orgch ] , let's take a
6
- look at the structure of the [ ` rust-lang/rust ` ] repository, where the rustc
6
+ look at the structure of the [ ` rust-lang/rust ` ] repository, where the ` rustc `
7
7
source code lives.
8
8
9
9
[ `rust-lang/rust` ] : https://github.com/rust-lang/rust
@@ -54,8 +54,8 @@ The repository consists of three main directories:
54
54
55
55
## Compiler
56
56
57
- The compiler is implemented in the various ` compiler/ ` crates.
58
- The ` compiler/ ` crates all have names starting with ` rustc_* ` . These are a
57
+ The compiler is implemented in the various [ ` compiler/ ` ] crates.
58
+ The [ ` compiler/ ` ] crates all have names starting with ` rustc_* ` . These are a
59
59
collection of around 50 interdependent crates ranging in size from tiny to
60
60
huge. There is also the ` rustc ` crate which is the actual binary (i.e. the
61
61
` main ` function); it doesn't actually do anything besides calling the
@@ -120,13 +120,13 @@ by the whole compiler (e.g. [`rustc_span`]). The very early parts of the
120
120
compilation process (e.g. [ parsing and the Abstract Syntax Tree (` AST ` )] [ parser ] )
121
121
depend on only these.
122
122
123
- After the ` AST ` is constructed and other early analysis is done, the compiler's
124
- [ query system] [ query ] gets set up. The query system is set up in a clever way
125
- using function pointers. This allows us to break dependencies between crates,
126
- allowing more parallel compilation. The query system is defined in
127
- [ ` rustc_middle ` ] , so nearly all subsequent parts of the compiler depend on this
128
- crate. It is a really large crate, leading to long compile times. Some efforts
129
- have been made to move stuff out of it with varying success. Another
123
+ After the [ ` AST ` ] [ parser ] is constructed and other early analysis is done, the
124
+ compiler's [ query system] [ query ] gets set up. The query system is set up in a
125
+ clever way using function pointers. This allows us to break dependencies
126
+ between crates, allowing more parallel compilation. The query system is defined
127
+ in [ ` rustc_middle ` ] , so nearly all subsequent parts of the compiler depend on
128
+ this crate. It is a really large crate, leading to long compile times. Some
129
+ efforts have been made to move stuff out of it with varying success. Another
130
130
side-effect is that sometimes related functionality gets scattered across
131
131
different crates. For example, linting functionality is found across earlier
132
132
parts of the crate, [ ` rustc_lint ` ] , [ ` rustc_middle ` ] , and other places.
@@ -139,7 +139,7 @@ so breaking things into separate crates has been our solution so far.
139
139
At the top of the dependency tree is [ ` rustc_driver ` ] and [ ` rustc_interface ` ]
140
140
which is an unstable wrapper around the query system helping drive various
141
141
stages of compilation. Other consumers of the compiler may use this interface
142
- in different ways (e.g. ` rustdoc ` or maybe eventually ` rust-analyzer ` ). The
142
+ in different ways (e.g. [ ` rustdoc ` ] or maybe eventually ` rust-analyzer ` ). The
143
143
[ ` rustc_driver ` ] crate first parses command line arguments and then uses
144
144
[ ` rustc_interface ` ] to drive the compilation to completion.
145
145
@@ -149,57 +149,56 @@ in different ways (e.g. `rustdoc` or maybe eventually `rust-analyzer`). The
149
149
150
150
## rustdoc
151
151
152
- The bulk of ` rustdoc ` is in [ ` librustdoc ` ] . However, the ` rustdoc ` binary
152
+ The bulk of [ ` rustdoc ` ] is in [ ` librustdoc ` ] . However, the [ ` rustdoc ` ] binary
153
153
itself is [ ` src/tools/rustdoc ` ] , which does nothing except call [ ` rustdoc::main ` ] .
154
154
155
155
There is also ` JavaScript ` and ` CSS ` for the docs in [ ` src/tools/rustdoc-js ` ]
156
156
and [ ` src/tools/rustdoc-themes ` ] .
157
157
158
- You can read more about ` rustdoc ` in [ this chapter] [ rustdocch ] .
158
+ You can read more about [ ` rustdoc ` ] in [ this chapter] [ `rustdoc` ] .
159
159
160
160
[ `librustdoc` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustdoc/index.html
161
161
[ `rustdoc::main` ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustdoc/fn.main.html
162
162
[ `src/tools/rustdoc-js` ] : https://github.com/rust-lang/rust/tree/master/src/tools/rustdoc-js
163
163
[ `src/tools/rustdoc-themes` ] : https://github.com/rust-lang/rust/tree/master/src/tools/rustdoc-themes
164
164
[ `src/tools/rustdoc` ] : https://github.com/rust-lang/rust/tree/master/src/tools/rustdoc
165
- [ rustdocch ] : ./rustdoc.md
165
+ [ `rustdoc` ] : ./rustdoc.md
166
166
167
167
## Tests
168
168
169
169
The test suite for all of the above is in [ ` tests/ ` ] . You can read more
170
170
about the test suite [ in this chapter] [ testsch ] .
171
171
172
- The test harness is in [ ` src/tools/compiletest ` ] .
172
+ The test harness is in [ ` src/tools/compiletest/ ` ] [ `compiletest/ `] .
173
173
174
- [ `src/tools/compiletest` ] : https://github.com/rust-lang/rust/tree/master/src/tools/compiletest
175
174
[ `tests/` ] : https://github.com/rust-lang/rust/tree/master/tests
176
175
[ testsch ] : ./tests/intro.md
177
176
178
177
## Build System
179
178
180
179
There are a number of tools in the repository just for building the compiler,
181
- standard library, ` rustdoc ` , etc, along with testing, building a full Rust
180
+ standard library, [ ` rustdoc ` ] , etc, along with testing, building a full Rust
182
181
distribution, etc.
183
182
184
- One of the primary tools is [ ` src/bootstrap ` ] . You can read more about
183
+ One of the primary tools is [ ` src/bootstrap/ ` ] . You can read more about
185
184
bootstrapping [ in this chapter] [ bootstch ] . The process may also use other tools
186
- from [ ` src/tools/ ` ] , such as [ ` tidy ` ] or [ ` compiletest ` ] .
185
+ from [ ` src/tools/ ` ] , such as [ ` tidy/ ` ] or [ ` compiletest/ ` ] .
187
186
188
- [ `compiletest` ] : https://github.com/rust-lang/rust/tree/master/src/tools/compiletest
189
- [ `src/bootstrap` ] : https://github.com/rust-lang/rust/tree/master/src/bootstrap
187
+ [ `compiletest/ ` ] : https://github.com/rust-lang/rust/tree/master/src/tools/compiletest
188
+ [ `src/bootstrap/ ` ] : https://github.com/rust-lang/rust/tree/master/src/bootstrap
190
189
[ `src/tools/` ] : https://github.com/rust-lang/rust/tree/master/src/tools
191
- [ `tidy` ] : https://github.com/rust-lang/rust/tree/master/src/tools/tidy
190
+ [ `tidy/ ` ] : https://github.com/rust-lang/rust/tree/master/src/tools/tidy
192
191
[ bootstch ] : ./building/bootstrapping.md
193
192
194
- ## Standard library (` libstd ` )
195
-
196
- The standard library crates are all in ` library/ ` . They have intuitive names
197
- like ` std ` , ` core ` , ` alloc ` , etc. There is also ` proc_macro ` , ` test ` , and
198
- other runtime libraries. The standard library is sometimes referred to as
199
- ` libstd ` .
193
+ ## Standard library (` std ` )
200
194
201
195
This code is fairly similar to most other Rust crates except that it must be
202
- built in a special way because it can use unstable (` nightly ` ) features.
196
+ built in a special way because it can use unstable ([ ` nightly ` ] ) features. The
197
+ standard library is sometimes referred to as [ `libstd or the "standard
198
+ facade"`] .
199
+
200
+ [ `libstd or the "standard facade"` ] : https://rust-lang.github.io/rfcs/0040-libstd-facade.html
201
+ [ `nightly` ] : https://doc.rust-lang.org/nightly/nightly-rustc/
203
202
204
203
## Other
205
204
0 commit comments