@@ -5,14 +5,14 @@ find useful.
5
5
6
6
## Getting started
7
7
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] .
12
12
13
13
[ Rust Zulip ] : https://rust-lang.zulipchat.com
14
14
15
- ## Building Miri with a pre-built rustc
15
+ ## Preparing the build environment
16
16
17
17
Miri heavily relies on internal rustc interfaces to execute MIR. Still, some
18
18
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:
28
28
29
29
[ `rustup-toolchain-install-master` ] : https://github.com/kennytm/rustup-toolchain-install-master
30
30
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:
32
36
33
37
```
34
38
./miri build
@@ -37,32 +41,16 @@ Now building Miri is just one command away:
37
41
Run ` ./miri ` without arguments to see the other commands our build tool
38
42
supports.
39
43
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
54
45
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 ] .
57
50
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
62
52
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
66
54
67
55
``` sh
68
56
./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
99
87
In addition, you can set ` MIRI_BACKTRACE=1 ` to get a backtrace of where an
100
88
evaluation error was originally raised.
101
89
102
- ## Testing ` cargo miri `
90
+ ### Testing ` cargo miri `
103
91
104
92
Working with the driver directly gives you full control, but you also lose all
105
93
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
117
105
` ./run-test.py ` in there to execute it. Like ` ./miri test ` , this respects the
118
106
` MIRI_TEST_TARGET ` environment variable to execute the test for another target.
119
107
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
121
126
122
127
A big part of the Miri driver lives in rustc, so working on Miri will sometimes
123
128
require using a locally built rustc. The bug you want to fix may actually be on
@@ -143,4 +148,4 @@ rustup override set custom
143
148
```
144
149
145
150
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