Skip to content

Commit f68e11b

Browse files
committed
A few small improvements to the contributing docs
1 parent a3a7203 commit f68e11b

File tree

2 files changed

+64
-14
lines changed

2 files changed

+64
-14
lines changed

CONTRIBUTING.md

+28-4
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,17 @@ There are large number of options provided in this config file that will alter t
112112
configuration used in the build process. Some options to note:
113113

114114
#### `[llvm]`:
115+
- `assertions = true` = This enables LLVM assertions, which makes LLVM misuse cause an assertion failure instead of weird misbehavior. This also slows down the compiler's runtime by ~20%.
115116
- `ccache = true` - Use ccache when building llvm
116117

117118
#### `[build]`:
118119
- `compiler-docs = true` - Build compiler documentation
119120

120121
#### `[rust]`:
121-
- `debuginfo = true` - Build a compiler with debuginfo
122-
- `optimize = false` - Disable optimizations to speed up compilation of stage1 rust
122+
- `debuginfo = true` - Build a compiler with debuginfo. Makes building rustc slower, but then you can use a debugger to debug `rustc`.
123+
- `debuginfo-lines = true` - An alternative to `debuginfo = true` that doesn't let you use a debugger, but doesn't make building rustc slower and still gives you line numbers in backtraces.
124+
- `debug-assertions = true` - Makes the log output of `debug!` work.
125+
- `optimize = false` - Disable optimizations to speed up compilation of stage1 rust, but makes the stage1 compiler x100 slower.
123126

124127
For more options, the `config.toml` file contains commented out defaults, with
125128
descriptions of what each option will do.
@@ -273,6 +276,27 @@ build, you'll need to build rustdoc specially, since it's not normally built in
273276
stage 1. `python x.py build --stage 1 src/libstd src/tools/rustdoc` will build
274277
rustdoc and libstd, which will allow rustdoc to be run with that toolchain.)
275278

279+
### Out-of-tree builds
280+
[out-of-tree-builds]: #out-of-tree-builds
281+
282+
Rust's `x.py` script fully supports out-of-tree builds - it looks for
283+
the Rust source code from the directory `x.py` was found in, but it
284+
reads the `config.toml` configuration file from the directory it's
285+
run in, and places all build artifacts within a subdirectory named `build`.
286+
287+
This means that if you want to do an out-of-tree build, you can just do it:
288+
```
289+
$ cd my/build/dir
290+
$ cp ~/my-config.toml config.toml # Or fill in config.toml otherwise
291+
$ path/to/rust/x.py build
292+
...
293+
$ # This will use the Rust source code in `path/to/rust`, but build
294+
$ # artifacts will now be in ./build
295+
```
296+
297+
It's absolutely fine to have multiple build directories with different
298+
`config.toml` configurations using the same code.
299+
276300
## Pull Requests
277301
[pull-requests]: #pull-requests
278302

@@ -446,14 +470,14 @@ failed to run: ~/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --ma
446470
If you haven't used the `[patch]`
447471
section of `Cargo.toml` before, there is [some relevant documentation about it
448472
in the cargo docs](http://doc.crates.io/manifest.html#the-patch-section). In
449-
addition to that, you should read the
473+
addition to that, you should read the
450474
[Overriding dependencies](http://doc.crates.io/specifying-dependencies.html#overriding-dependencies)
451475
section of the documentation as well.
452476

453477
Specifically, the following [section in Overriding dependencies](http://doc.crates.io/specifying-dependencies.html#testing-a-bugfix) reveals what the problem is:
454478

455479
> Next up we need to ensure that our lock file is updated to use this new version of uuid so our project uses the locally checked out copy instead of one from crates.io. The way [patch] works is that it'll load the dependency at ../path/to/uuid and then whenever crates.io is queried for versions of uuid it'll also return the local version.
456-
>
480+
>
457481
> This means that the version number of the local checkout is significant and will affect whether the patch is used. Our manifest declared uuid = "1.0" which means we'll only resolve to >= 1.0.0, < 2.0.0, and Cargo's greedy resolution algorithm also means that we'll resolve to the maximum version within that range. Typically this doesn't matter as the version of the git repository will already be greater or match the maximum version published on crates.io, but it's important to keep this in mind!
458482
459483
This says that when we updated the submodule, the version number in our

src/test/COMPILER_TESTS.md

+36-10
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,24 @@ The error levels that you can have are:
3535
## Summary of Header Commands
3636

3737
Header commands specify something about the entire test file as a
38-
whole, instead of just a few lines inside the test.
38+
whole. They are normally put right after the copyright comment, e.g.:
39+
40+
```Rust
41+
// Copyright blah blah blah
42+
// except according to those terms.
43+
44+
// ignore-test This doesn't actually work
45+
```
46+
47+
### Ignoring tests
48+
49+
These are used to ignore the test in some situations, which means the test won't
50+
be compiled or run.
3951

4052
* `ignore-X` where `X` is a target detail or stage will ignore the test accordingly (see below)
4153
* `ignore-pretty` will not compile the pretty-printed test (this is done to test the pretty-printer, but might not always work)
4254
* `ignore-test` always ignores the test
43-
* `ignore-lldb` and `ignore-gdb` will skip the debuginfo tests
44-
* `min-{gdb,lldb}-version`
45-
* `should-fail` indicates that the test should fail; used for "meta testing",
46-
where we test the compiletest program itself to check that it will generate
47-
errors in appropriate scenarios. This header is ignored for pretty-printer tests.
48-
* `gate-test-X` where `X` is a feature marks the test as "gate test" for feature X.
49-
Such tests are supposed to ensure that the compiler errors when usage of a gated
50-
feature is attempted without the proper `#![feature(X)]` tag.
51-
Each unstable lang feature is required to have a gate test.
55+
* `ignore-lldb` and `ignore-gdb` will skip a debuginfo test on that debugger.
5256

5357
Some examples of `X` in `ignore-X`:
5458

@@ -58,6 +62,22 @@ Some examples of `X` in `ignore-X`:
5862
* Pointer width: `32bit`, `64bit`.
5963
* Stage: `stage0`, `stage1`, `stage2`.
6064

65+
### Other Header Commands
66+
67+
* `min-{gdb,lldb}-version`
68+
* `min-llvm-version`
69+
* `must-compile-successfully` for UI tests, indicates that the test is supposed
70+
to compile, as opposed to the default where the test is supposed to error out.
71+
* `compile-flags` passes extra command-line args to the compiler,
72+
e.g. `compile-flags -g` which forces debuginfo to be enabled.
73+
* `should-fail` indicates that the test should fail; used for "meta testing",
74+
where we test the compiletest program itself to check that it will generate
75+
errors in appropriate scenarios. This header is ignored for pretty-printer tests.
76+
* `gate-test-X` where `X` is a feature marks the test as "gate test" for feature X.
77+
Such tests are supposed to ensure that the compiler errors when usage of a gated
78+
feature is attempted without the proper `#![feature(X)]` tag.
79+
Each unstable lang feature is required to have a gate test.
80+
6181
## Revisions
6282

6383
Certain classes of tests support "revisions" (as of the time of this
@@ -109,6 +129,12 @@ fails, we will print out the current output, but it is also saved in
109129
printed as part of the test failure message), so you can run `diff` and
110130
so forth.
111131

132+
Normally, the test-runner checks that UI tests fail compilation. If you want
133+
to do a UI test for code that *compiles* (e.g. to test warnings, or if you
134+
have a collection of tests, only some of which error out), you can use the
135+
`// must-compile-successfully` header command to have the test runner instead
136+
check that the test compiles successfully.
137+
112138
### Editing and updating the reference files
113139

114140
If you have changed the compiler's output intentionally, or you are

0 commit comments

Comments
 (0)