Open oli-obk opened 7 years ago
Build yourself a rustc with -Zalways-encode-mir (stage2 build necessary)
Where does that flag have to be added?
Good question. I turned it on unconditionally in the source... I should probably add a config.toml flag
This issue is pretty old, but every few months someone on the community Discord will point out some dodgy code in rustc and everyone will clamor that we should run Miri on rustc or Miri on Miri. So I think it's fair to say that there is ambient interest in this, if it were made more accessible.
I looked over the instructions above and I think there is a bit missing.
-Zalways-encode-mir
? The instructions mention a stage2 build, so does one set RUSTFLAGS_BOOTSTRAP
or RUSTFLAGS_NOT_BOOTSTRAP
? Both?-Zmir-opt-level=3
? I thought the whole point of Miri was to run on fully unoptimized MIR.cargo run --bin miri/bin/miri.rs
which seems wrong? I've only ever build/run inside the repo with ./miri
. Is this use of cargo run
directly correct?
- How does one provide
-Zalways-encode-mir
? The instructions mention a stage2 build, so does one setRUSTFLAGS_BOOTSTRAP
orRUSTFLAGS_NOT_BOOTSTRAP
? Both?
only RUSTFLAGS_NOT_BOOTSTRAP
should be necessary
2. What's up with the
-Zmir-opt-level=3
? I thought the whole point of Miri was to run on fully unoptimized MIR.
that was just me hoping it would run faster that way ^^
3. Instructions mention
cargo run --bin miri/bin/miri.rs
which seems wrong? I've only ever build/run inside the repo with./miri
. Is this use ofcargo run
directly correct?
yea that's really old. I think if you install miri in step 3 you can use cargo miri run
inside the miri repository itself
With this in my config.toml
:
extended = true
tools = ["cargo", "clippy", "rustfmt", "src", "miri"]
I ran this to build rustc:
RUSTFLAGS_NOT_BOOTSTRAP x build --stage 2
Then based on the contents of the miri
script, I ran
export RUSTFLAGS="-C link-args=-Wl,-rpath,/home/ben/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib"
Then tried to
cargo +stage2 miri run --bin miri --verbose
And all I see is:
Running `/home/ben/.cargo/bin/cargo-miri /home/ben/.cargo/bin/miri --crate-name miri --edition=2021 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="stack-cache"' -C metadata=24c414736c1dfa74 -C extra-filename=-24c414736c1dfa74 --out-dir /home/ben/miri/target/miri/x86_64-unknown-linux-gnu/debug/deps --target x86_64-unknown-linux-gnu -C linker=clang -C incremental=/home/ben/miri/target/miri/x86_64-unknown-linux-gnu/debug/incremental -L dependency=/home/ben/miri/target/miri/x86_64-unknown-linux-gnu/debug/deps -L dependency=/home/ben/miri/target/miri/debug/deps --extern env_logger=/home/ben/miri/target/miri/x86_64-unknown-linux-gnu/debug/deps/libenv_logger-6f6d8da2b7ee6306.rmeta --extern getrandom=/home/ben/miri/target/miri/x86_64-unknown-linux-gnu/debug/deps/libgetrandom-d277bf60883b4b86.rmeta --extern libc=/home/ben/miri/target/miri/x86_64-unknown-linux-gnu/debug/deps/liblibc-ed6a90483caf3f1a.rmeta --extern libffi=/home/ben/miri/target/miri/x86_64-unknown-linux-gnu/debug/deps/liblibffi-f56d2af76a51dbca.rmeta --extern libloading=/home/ben/miri/target/miri/x86_64-unknown-linux-gnu/debug/deps/liblibloading-7816860288464c34.rmeta --extern log=/home/ben/miri/target/miri/x86_64-unknown-linux-gnu/debug/deps/liblog-fea090e2364200e8.rmeta --extern measureme=/home/ben/miri/target/miri/x86_64-unknown-linux-gnu/debug/deps/libmeasureme-25a6023984e08d37.rmeta --extern rand=/home/ben/miri/target/miri/x86_64-unknown-linux-gnu/debug/deps/librand-f84f5437562e1f0a.rmeta --extern rustc_workspace_hack=/home/ben/miri/target/miri/x86_64-unknown-linux-gnu/debug/deps/librustc_workspace_hack-2ee5e29a45fa7105.rmeta --extern shell_escape=/home/ben/miri/target/miri/x86_64-unknown-linux-gnu/debug/deps/libshell_escape-f71c5889ef27c6e3.rmeta --extern smallvec=/home/ben/miri/target/miri/x86_64-unknown-linux-gnu/debug/deps/libsmallvec-e028de92ed4a41db.rmeta -C link-args=-Wl,-rpath,/home/ben/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib -L /home/ben/miri/target/miri/x86_64-unknown-linux-gnu/debug/build/libffi-sys-b8d8cd4be8d71230/out/libffi-root/lib -L /home/ben/miri/target/miri/x86_64-unknown-linux-gnu/debug/build/libffi-sys-b8d8cd4be8d71230/out/libffi-root/lib64`
error[E0463]: can't find crate for `rustc_apfloat`
--> src/lib.rs:42:1
|
42 | extern crate rustc_apfloat;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
|
= help: maybe you need to install the missing components with: `rustup component add rust-src rustc-dev llvm-tools-preview`
and more missing rustc_
crates then a cascade of errors from missing them.
There is for example a rustc_apfloat
rlib in the directory mentioned in my RUSTFLAGS
. Do you have any idea what's going on here?
The rustc-dev compoment needs to be installed.
This issue is just to document my process. It's ridiculously slow, but a lot of fun.
-Zalways-encode-mir
(stage2 build necessary)stage2
)RUSTFLAGS=-Zalways-encode-mir -Zmir-opt-level=3
--extern
flags and the-L dependency=...
flagRUSTFLAGS=-Zalways-encode-mir -Zmir-opt-level=3 rustup run stage2 cargo run --bin miri/bin/miri.rs --verbose -- -Zmir-opt-level=3
and append all the flags from 4. after that command line