Description
Discussed briefly on IRC with @shepmaster: It would be great if the playground could run programs in miri. That's a MIR interpreter. One reason why one might want to do this is that miri will stop program execution when there is UB -- the checks are not complete yet, but more are coming. It will never be able to detect all kinds of UB (e.g. relying on how #[repr(Rust)]
lays out data is hard to detect), but the idea is it should detect e.g. violation of the pointer aliasing rules.
Since I don't know how the playground works, I'll just give instructions for how to run miri manually. All of this has to happen with a nightly compiler.
Setup:
git clone https://github.com/solson/miri && cd miri
cargo install xargo
xargo/build.sh
- Now xargo is no longer needed and could be uninstalled; the purpose was just to obtain the files that now live in
~/.xargo/HOST
. cargo install --all-features --force
Now, when you are in a crate, instead of cargo run
you would do MIRI_SYSROOT=~/.xargo/HOST cargo miri -- -Zmiri-start-fn
. That's it.