Skip to content

Commit 9622070

Browse files
committed
Auto merge of rust-lang#2698 - RalfJung:miri-in-rustc, r=oli-obk
replace 'locally built rustc' instructions by 'Miri in rustc'
2 parents 76ae2f5 + 75e040e commit 9622070

File tree

1 file changed

+14
-47
lines changed

1 file changed

+14
-47
lines changed

CONTRIBUTING.md

+14-47
Original file line numberDiff line numberDiff line change
@@ -203,65 +203,32 @@ for more information about configuring VS Code and `rust-analyzer`.
203203

204204
[rdg-r-a]: https://rustc-dev-guide.rust-lang.org/building/suggested.html#configuring-rust-analyzer-for-rustc
205205

206-
## Advanced topic: other build environments
206+
## Advanced topic: Working on Miri in the rustc tree
207207

208208
We described above the simplest way to get a working build environment for Miri,
209209
which is to use the version of rustc indicated by `rustc-version`. But
210210
sometimes, that is not enough.
211211

212-
### Building Miri with a locally built rustc
212+
A big part of the Miri driver is shared with rustc, so working on Miri will
213+
sometimes require also working on rustc itself. In this case, you should *not*
214+
work in a clone of the Miri repository, but in a clone of the
215+
[main Rust repository](https://github.com/rust-lang/rust/). There is a copy of
216+
Miri located at `src/tools/miri` that you can work on directly. A maintainer
217+
will eventually sync those changes back into this repository.
213218

214-
[building Miri with a locally built rustc]: #building-miri-with-a-locally-built-rustc
219+
When working on Miri in the rustc tree, here's how you can run tests:
215220

216-
A big part of the Miri driver lives in rustc, so working on Miri will sometimes
217-
require using a locally built rustc. The bug you want to fix may actually be on
218-
the rustc side, or you just need to get more detailed trace of the execution
219-
than what is possible with release builds -- in both cases, you should develop
220-
Miri against a rustc you compiled yourself, with debug assertions (and hence
221-
tracing) enabled.
222-
223-
The setup for a local rustc works as follows:
224-
```sh
225-
# Clone the rust-lang/rust repo.
226-
git clone https://github.com/rust-lang/rust rustc
227-
cd rustc
228-
# Create a config.toml with defaults for working on Miri.
229-
./x.py setup compiler
230-
# Now edit `config.toml` and under `[rust]` set `debug-assertions = true`.
231-
232-
# Build a stage 2 rustc, and build the rustc libraries with that rustc.
233-
# This step can take 30 minutes or more.
234-
./x.py build --stage 2 compiler/rustc
235-
# If you change something, you can get a faster rebuild by doing
236-
./x.py build --keep-stage 0 --stage 2 compiler/rustc
237-
# You may have to change the architecture in the next command
238-
rustup toolchain link stage2 build/x86_64-unknown-linux-gnu/stage2
239-
# Now cd to your Miri directory, then configure rustup
240-
rustup override set stage2
241221
```
242-
243-
Note: When you are working with a locally built rustc or any other toolchain that
244-
is not the same as the one in `rust-version`, you should not have `.auto-everything` or
245-
`.auto-toolchain` as that will keep resetting your toolchain.
246-
247-
```sh
248-
rm -f .auto-everything .auto-toolchain
222+
./x.py test miri --stage 0
249223
```
250224

251-
Important: You need to delete the Miri cache when you change the stdlib; otherwise the
252-
old, chached version will be used. On Linux, the cache is located at `~/.cache/miri`,
253-
and on Windows, it is located at `%LOCALAPPDATA%\rust-lang\miri\cache`; the exact
254-
location is printed after the library build: "A libstd for Miri is now available in ...".
255-
256-
Note: `./x.py --stage 2 compiler/rustc` currently errors with `thread 'main'
257-
panicked at 'fs::read(stamp) failed with No such file or directory (os error 2)`,
258-
you can simply ignore that error; Miri will build anyway.
225+
`--bless` will work, too.
259226

260-
For more information about building and configuring a local compiler,
261-
see <https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html>.
227+
You can also directly run Miri on a Rust source file:
262228

263-
With this, you should now have a working development setup! See
264-
[above](#building-and-testing-miri) for how to proceed working on Miri.
229+
```
230+
./x.py run miri --stage 0 --args src/tools/miri/tests/pass/hello.rs
231+
```
265232

266233
## Advanced topic: Syncing with the rustc repo
267234

0 commit comments

Comments
 (0)