Skip to content

Commit d403d82

Browse files
authored
Rollup merge of rust-lang#49707 - steveklabnik:rustc-book, r=QuietMisdreavus
Add "the Rustc book" This PR introduces a new book into the documentation, "The rustc book". We already have books for Cargo, and for Rustdoc, rustc should have some too. This book is focused on *users* of rustc, and provides a nice place to write documentation for users. I haven't put content here, but plan on scaffolding it out very soon, and wanted this PR open for a few discussions first. One of those is "what exactly should said TOC be?" I plan on having a proposed one up tomorrow, but figured I'd let people know to start thinking about it now. The big one is that we also will want to put https://github.com/rust-lang-nursery/rustc-guide in-tree as well, and the naming is... tough. I'm proposing: * doc.rust-lang.org/rustc is "The Rustc book", to mirror the other tools' books. * doc.rust-lang.org/rustc-contribution is "The Rustc contribution guide", and contains that book @nikomatsakis et al, any thoughts on this? I'm not attached to it in particular, but had to put something together to get this discussion going. I think mirroring the other tools is a good idea for this work, but am not sure where exactly that leaves yours. Fixes rust-docs/team#11
2 parents e05b78d + 36475d9 commit d403d82

21 files changed

+2516
-2
lines changed

src/bootstrap/builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,15 @@ impl<'a> Builder<'a> {
323323
test::Cargotest, test::Cargo, test::Rls, test::ErrorIndex, test::Distcheck,
324324
test::RunMakeFullDeps,
325325
test::Nomicon, test::Reference, test::RustdocBook, test::RustByExample,
326-
test::TheBook, test::UnstableBook,
326+
test::TheBook, test::UnstableBook, test::RustcBook,
327327
test::Rustfmt, test::Miri, test::Clippy, test::RustdocJS, test::RustdocTheme,
328328
// Run run-make last, since these won't pass without make on Windows
329329
test::RunMake, test::RustdocUi),
330330
Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
331331
Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook,
332332
doc::Standalone, doc::Std, doc::Test, doc::WhitelistedRustc, doc::Rustc,
333333
doc::ErrorIndex, doc::Nomicon, doc::Reference, doc::Rustdoc, doc::RustByExample,
334-
doc::CargoBook),
334+
doc::RustcBook, doc::CargoBook),
335335
Kind::Dist => describe!(dist::Docs, dist::RustcDocs, dist::Mingw, dist::Rustc,
336336
dist::DebuggerScripts, dist::Std, dist::Analysis, dist::Src,
337337
dist::PlainSourceTarball, dist::Cargo, dist::Rls, dist::Rustfmt, dist::Extended,

src/bootstrap/doc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ book!(
7171
Nomicon, "src/doc/nomicon", "nomicon";
7272
Reference, "src/doc/reference", "reference";
7373
Rustdoc, "src/doc/rustdoc", "rustdoc";
74+
RustcBook, "src/doc/rustc", "rustc";
7475
RustByExample, "src/doc/rust-by-example", "rust-by-example";
7576
);
7677

src/bootstrap/test.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,7 @@ test_book!(
12121212
Nomicon, "src/doc/nomicon", "nomicon", default=false;
12131213
Reference, "src/doc/reference", "reference", default=false;
12141214
RustdocBook, "src/doc/rustdoc", "rustdoc", default=true;
1215+
RustcBook, "src/doc/rustc", "rustc", default=true;
12151216
RustByExample, "src/doc/rust-by-example", "rust-by-example", default=false;
12161217
TheBook, "src/doc/book", "book", default=false;
12171218
UnstableBook, "src/doc/unstable-book", "unstable-book", default=true;

src/doc/index.md

+4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ Rust's standard library has [extensive API documentation](std/index.html),
4343
with explanations of how to use various things, as well as example code for
4444
accomplishing various tasks.
4545

46+
## The Rustc Book
47+
48+
[The Rustc Book](rustc/index.html) describes the Rust compiler, `rustc`.
49+
4650
## The Cargo Book
4751

4852
[The Cargo Book](cargo/index.html) is a guide to Cargo, Rust's build tool and dependency manager.

src/doc/rustc/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
book

src/doc/rustc/book.toml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[book]
2+
authors = ["The Rust Project Developers"]
3+
multilingual = false
4+
src = "src"
5+
title = "The rustc book"

src/doc/rustc/src/SUMMARY.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# The Rustc Book
2+
3+
- [What is rustc?](what-is-rustc.md)
4+
- [Command-line arguments](command-line-arguments.md)
5+
- [Lints](lints/index.md)
6+
- [Lint levels](lints/levels.md)
7+
- [Lint Groups](lints/groups.md)
8+
- [Lint listing](lints/listing/index.md)
9+
- [Allowed-by-default lints](lints/listing/allowed-by-default.md)
10+
- [Warn-by-default lints](lints/listing/warn-by-default.md)
11+
- [Deny-by-default lints](lints/listing/deny-by-default.md)
12+
- [Codegen options](codegen-options/index.md)
13+
- [Targets](targets/index.md)
14+
- [Built-in Targets](targets/built-in.md)
15+
- [Custom Targets](targets/custom.md)
16+
- [Contributing to `rustc`](contributing.md)
+209
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
# Codegen options
2+
3+
All of these options are passed to `rustc` via the `-C` flag, short for "codegen." You can see
4+
a version of this list for your exact compiler by running `rustc -C help`.
5+
6+
## ar
7+
8+
This option is deprecated and does nothing.
9+
10+
## linker
11+
12+
This flag lets you control which linker `rustc` invokes to link your code.
13+
14+
## link-arg=val
15+
16+
This flag lets you append a single extra argument to the linker invocation.
17+
18+
"Append" is significant; you can pass this flag multiple times to add multiple arguments.
19+
20+
## link-args
21+
22+
This flag lets you append multiple extra arguments to the linker invocation. The
23+
options should be separated by spaces.
24+
25+
## link-dead-code
26+
27+
Normally, the linker will remove dead code. This flag disables this behavior.
28+
29+
An example of when this flag might be useful is when trying to construct code coverage
30+
metrics.
31+
32+
## lto
33+
34+
This flag instructs LLVM to use [link time
35+
optimizations](https://llvm.org/docs/LinkTimeOptimization.html).
36+
37+
It takes one of two values, `thin` and `fat`. 'thin' LTO [is a new feature of
38+
LLVM](http://blog.llvm.org/2016/06/thinlto-scalable-and-incremental-lto.html),
39+
'fat' referring to the classic version of LTO.
40+
41+
## target-cpu
42+
43+
This instructs `rustc` to generate code specifically for a particular processor.
44+
45+
You can run `rustc --print target-cpus` to see the valid options to pass
46+
here. Additionally, `native` can be passed to use the processor of the host
47+
machine.
48+
49+
## target-feature
50+
51+
Individual targets will support different features; this flag lets you control
52+
enabling or disabling a feature.
53+
54+
To see the valid options and an example of use, run `rustc --print
55+
target-features`.
56+
57+
## passes
58+
59+
This flag can be used to add extra LLVM passes to the compilation.
60+
61+
The list must be separated by spaces.
62+
63+
## llvm-args
64+
65+
This flag can be used to pass a list of arguments directly to LLVM.
66+
67+
The list must be separated by spaces.
68+
69+
## save-temps
70+
71+
`rustc` will generate temporary files during compilation; normally it will
72+
delete them after it's done with its work. This option will cause them to be
73+
preserved instead of removed.
74+
75+
## rpath
76+
77+
This option allows you to set the value of
78+
[`rpath`](https://en.wikipedia.org/wiki/Rpath).
79+
80+
## overflow-checks
81+
82+
This flag allows you to control the behavior of integer overflow. This flag
83+
can be passed many options:
84+
85+
* To turn overflow checks on: `y`, `yes`, or `on`.
86+
* To turn overflow checks off: `n`, `no`, or `off`.
87+
88+
## no-prepopulate-passes
89+
90+
The pass manager comes pre-populated with a list of passes; this flag
91+
ensures that list is empty.
92+
93+
## no-vectorize-loops
94+
95+
By default, `rustc` will attempt to [vectorize
96+
loops](https://llvm.org/docs/Vectorizers.html#the-loop-vectorizer). This
97+
flag will turn that behavior off.
98+
99+
## no-vectorize-slp
100+
101+
By default, `rustc` will attempt to vectorize loops using [superword-level
102+
parallelism](https://llvm.org/docs/Vectorizers.html#the-slp-vectorizer). This
103+
flag will turn that behavior off.
104+
105+
## soft-float
106+
107+
This option will make `rustc` generate code using "soft floats." By default,
108+
a lot of hardware supports floating point instructions, and so the code generated
109+
will take advantage of this. "soft floats" emulate floating point instructions
110+
in software.
111+
112+
## prefer-dynamic
113+
114+
By default, `rustc` prefers to statically link dependencies. This option will
115+
make it use dynamic linking instead.
116+
117+
## no-integrated-as
118+
119+
LLVM comes with an internal assembler; this option will let you use an
120+
external assembler instead.
121+
122+
## no-redzone
123+
124+
This flag allows you to disable [the
125+
red zone](https://en.wikipedia.org/wiki/Red_zone_\(computing\)). This flag can
126+
be passed many options:
127+
128+
* To enable the red zone: `y`, `yes`, or `on`.
129+
* To disable it: `n`, `no`, or `off`.
130+
131+
## relocation-model
132+
133+
This option lets you choose which relocation model to use.
134+
135+
To find the valid options for this flag, run `rustc --print relocation-models`.
136+
137+
## code-model=val
138+
139+
This option lets you choose which code model to use.
140+
141+
To find the valid options for this flag, run `rustc --print code-models`.
142+
143+
## metadata
144+
145+
This option allows you to control the metadata used for symbol mangling.
146+
147+
## extra-filename
148+
149+
This option allows you to put extra data in each output filename.
150+
151+
## codegen-units
152+
153+
This flag lets you control how many threads are used when doing
154+
code generation.
155+
156+
Increasing paralellism may speed up compile times, but may also
157+
produce slower code.
158+
159+
## remark
160+
161+
This flag lets you print remarks for these optimization passes.
162+
163+
The list of passes should be separated by spaces.
164+
165+
`all` will remark on every pass.
166+
167+
## no-stack-check
168+
169+
This option is deprecated and does nothing.
170+
171+
## debuginfo
172+
173+
This flag lets you control debug information:
174+
175+
* `0`: no debug info at all
176+
* `1`: line tables only
177+
* `2`: full debug info
178+
179+
## opt-level
180+
181+
This flag lets you control the optimization level.
182+
183+
* `0`: no optimizations
184+
* `1`: basic optimizations
185+
* `2`: some optimizations
186+
* `3`: all optimizations
187+
* `s`: optimize for binary size
188+
* `z`: optimize for binary size, but also turn off loop vectorization.
189+
190+
## debug-assertions
191+
192+
This flag lets you turn `cfg(debug_assertions)` on or off.
193+
194+
## inline-threshold
195+
196+
This option lets you set the threshold for inlining a function.
197+
198+
The default is 225.
199+
200+
## panic
201+
202+
This option lets you control what happens when the code panics.
203+
204+
* `abort`: terminate the process upon panic
205+
* `unwind`: unwind the stack upon panic
206+
207+
## incremental
208+
209+
This flag allows you to enable incremental compilation.
+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Command-line arguments
2+
3+
Here's a list of command-line arguments to `rustc` and what they do.
4+
5+
## `-h`/`--help`: get help
6+
7+
This flag will print out help information for `rustc`.
8+
9+
## `--cfg`: configure the compilation environment
10+
11+
This flag can turn on or off various `#[cfg]` settings.
12+
13+
## `-L`: add a directory to the library search path
14+
15+
When looking for external crates, a directory passed to this flag will be searched.
16+
17+
## `-l`: link the generated crate to a native library
18+
19+
This flag allows you to specify linking to a specific native library when building
20+
a crate.
21+
22+
## `--crate-type`: a list of types of crates for the compiler to emit
23+
24+
This instructs `rustc` on which crate type to build.
25+
26+
## `--crate-name`: specify the name of the crate being built
27+
28+
This informs `rustc` of the name of your crate.
29+
30+
## `--emit`: emit output other than a crate
31+
32+
Instead of producing a crate, this flag can print out things like the assembly or LLVM-IR.
33+
34+
## `--print`: print compiler information
35+
36+
This flag prints out various information about the compiler.
37+
38+
## `-g`: include debug information
39+
40+
A synonym for `-C debug-level=2`.
41+
42+
## `-O`: optimize your code
43+
44+
A synonym for `-C opt-level=2`.
45+
46+
## `-o`: filename of the output
47+
48+
This flag controls the output filename.
49+
50+
## `--out-dir`: directory to write the output in
51+
52+
The outputted crate will be written to this directory.
53+
54+
## `--explain`: provide a detailed explanation of an error message
55+
56+
Each error of `rustc`'s comes with an error code; this will print
57+
out a longer explanation of a given error.
58+
59+
## `--test`: build a test harness
60+
61+
When compiling this crate, `rustc` will ignore your `main` function
62+
and instead produce a test harness.
63+
64+
## `--target`: select a target triple to build
65+
66+
This controls which [target](targets/index.html) to produce.
67+
68+
## `-W`: set lint warnings
69+
70+
This flag will set which lints should be set to the [warn level](lints/levels.html#warn).
71+
72+
## `-A`: set lint allowed
73+
74+
This flag will set which lints should be set to the [allow level](lints/levels.html#allow).
75+
76+
## `-D`: set lint denied
77+
78+
This flag will set which lints should be set to the [deny level](lints/levels.html#deny).
79+
80+
## `-F`: set lint forbidden
81+
82+
This flag will set which lints should be set to the [forbid level](lints/levels.html#forbid).
83+
84+
## `--cap-lints`: set the most restrictive lint level
85+
86+
This flag lets you 'cap' lints, for more, [see here](lints/levels.html#capping-lints).
87+
88+
## `-C`/`--codegen`: code generation options
89+
90+
This flag will allow you to set [codegen options](codegen-options/index.html).
91+
92+
## `-V`/`--version`: print a version
93+
94+
This flag will print out `rustc`'s version.
95+
96+
## `-v`/`--verbose`: use verbose output
97+
98+
This flag, when combined with other flags, makes them produce extra output.
99+
100+
## `--extern`: specify where an external library is located
101+
102+
This flag allows you to pass the name and location of an external crate that will
103+
be linked into the crate you're buildling.
104+
105+
## `--sysroot`: Override the system root
106+
107+
The "sysroot" is where `rustc` looks for the crates that come with the Rust
108+
distribution; this flag allows that to be overridden.
109+
110+
## `--error-format`: control how errors are produced
111+
112+
This flag lets you control the format of errors.
113+
114+
## `--color`: configure coloring of output
115+
116+
This flag lets you control color settings of the output.

0 commit comments

Comments
 (0)