Skip to content

Commit 925465e

Browse files
committed
more editing for CONTRIBUTING guide
1 parent ac3a246 commit 925465e

File tree

1 file changed

+37
-32
lines changed

1 file changed

+37
-32
lines changed

CONTRIBUTING.md

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ find useful.
55

66
## Getting started
77

8-
Check out the issues on this GitHub repository for some ideas. There's lots that
9-
needs to be done that we haven't documented in the issues yet, however. For more
10-
ideas or help with hacking on Miri, you can contact us (`oli-obk` and `RalfJ`)
11-
on the [Rust Zulip].
8+
Check out the issues on this GitHub repository for some ideas. In particular,
9+
look for the green `E-*` labels which mark issues that should be rather
10+
well-suited for onboarding. For more ideas or help with hacking on Miri, you can
11+
contact us (`oli-obk` and `RalfJ`) on the [Rust Zulip].
1212

1313
[Rust Zulip]: https://rust-lang.zulipchat.com
1414

15-
## Building Miri with a pre-built rustc
15+
## Preparing the build environment
1616

1717
Miri heavily relies on internal rustc interfaces to execute MIR. Still, some
1818
things (like adding support for a new intrinsic or a shim for an external
@@ -28,7 +28,11 @@ install that exact version of rustc as a toolchain:
2828

2929
[`rustup-toolchain-install-master`]: https://github.com/kennytm/rustup-toolchain-install-master
3030

31-
Now building Miri is just one command away:
31+
## Building and testing Miri
32+
33+
Invoking Miri requires getting a bunch of flags right and setting up a custom
34+
sysroot with xargo. The `miri` script takes care of that for you. With the
35+
build environment prepared, compiling Miri is just one command away:
3236

3337
```
3438
./miri build
@@ -37,32 +41,16 @@ Now building Miri is just one command away:
3741
Run `./miri` without arguments to see the other commands our build tool
3842
supports.
3943

40-
### Fixing Miri when rustc changes
41-
42-
Miri is heavily tied to rustc internals, so it is very common that rustc changes
43-
break Miri. Fixing those is a good way to get starting working on Miri.
44-
Usually, Miri will require changes similar to the other consumers of the changed
45-
rustc API, so reading the rustc PR diff is a good way to get an idea for what is
46-
needed.
47-
48-
To update the `rustc-version` file and install the latest rustc, you can run:
49-
```
50-
./rustup-toolchain HEAD
51-
```
52-
53-
Now try `./miri test`, and submit a PR once that works again.
44+
### Testing the Miri driver
5445

55-
## Testing the Miri driver
56-
[testing-miri]: #testing-the-miri-driver
46+
The Miri driver in the `src/bin/miri.rs` binary is the "heart" of Miri: it is
47+
basically a version of `rustc` that, instead of compiling your code, runs it.
48+
It accepts all the same flags as `rustc` (though the ones only affecting code
49+
generation and linking obviously will have no effect) [and more][miri-flags].
5750

58-
The Miri driver in the `miri` binary is the "heart" of Miri: it is basically a
59-
version of `rustc` that, instead of compiling your code, runs it. It accepts
60-
all the same flags as `rustc` (though the ones only affecting code generation
61-
and linking obviously will have no effect) [and more][miri-flags].
51+
[miri-flags]: README.md#miri--z-flags-and-environment-variables
6252

63-
Running the Miri driver requires some fiddling with environment variables, so
64-
the `miri` script helps you do that. For example, you can (cross-)run the
65-
driver on a particular file by doing
53+
For example, you can (cross-)run the driver on a particular file by doing
6654

6755
```sh
6856
./miri run tests/run-pass/format.rs
@@ -99,7 +87,7 @@ MIRI_LOG=rustc_mir::interpret=info,miri::stacked_borrows ./miri run tests/run-pa
9987
In addition, you can set `MIRI_BACKTRACE=1` to get a backtrace of where an
10088
evaluation error was originally raised.
10189

102-
## Testing `cargo miri`
90+
### Testing `cargo miri`
10391

10492
Working with the driver directly gives you full control, but you also lose all
10593
the convenience provided by cargo. Once your test case depends on a crate, it
@@ -117,7 +105,24 @@ There's a test for the cargo wrapper in the `test-cargo-miri` directory; run
117105
`./run-test.py` in there to execute it. Like `./miri test`, this respects the
118106
`MIRI_TEST_TARGET` environment variable to execute the test for another target.
119107

120-
## Building Miri with a locally built rustc
108+
### Fixing Miri when rustc changes
109+
110+
Miri is heavily tied to rustc internals, so it is very common that rustc changes
111+
break Miri. Usually, Miri will require changes similar to the other consumers
112+
of the changed rustc API, so reading the rustc PR diff is a good way to get an
113+
idea for what is needed.
114+
115+
To update the `rustc-version` file and install the latest rustc, you can run:
116+
```
117+
./rustup-toolchain HEAD
118+
```
119+
120+
Now try `./miri test`, and submit a PR once that works again. Even if you choose
121+
not to use `./rustup-toolchain`, it is important that the `rustc-version` file
122+
is updated, as our CI makes sure that Miri works well with that particular
123+
version of rustc.
124+
125+
## Advanced topic: Building Miri with a locally built rustc
121126

122127
A big part of the Miri driver lives in rustc, so working on Miri will sometimes
123128
require using a locally built rustc. The bug you want to fix may actually be on
@@ -143,4 +148,4 @@ rustup override set custom
143148
```
144149

145150
With this, you should now have a working development setup! See
146-
[above][testing-miri] for how to proceed working with the Miri driver.
151+
[above](#building-and-testing-miri) for how to proceed working on Miri.

0 commit comments

Comments
 (0)