Description
Moving miri to the compiler made development with miri significantly harder. To avoid rebuilding the compiler twice on every change in librustc_mir/interpret
, I usually do ./x.py build src/rustc --keep-stage 0
. This still does unnecessary work, however, when changing libstd (but that is likely hard to avoid?). Also --keep-stage
is somewhat fragile. So overall, developing miri is much more cumbersome than previously (and that's not even talking about it being much harder to land patches, and much more likely to get merge conflicts, but that part is unavoidable).
It would be great if one could build, test and run miri in earlier stages. The building part actually works, but only with a trick:
$ CARGO_CFG_REGEX_DISABLE_AUTO_OPTIMIZATIONS=1 ./x.py --stage 0 build src/tools/miri
The env var is needed because stage 0 libstd does not contain std::arch
. Could we change that?
Running works but is not very straight-forward
$ cp build/x86_64-unknown-linux-gnu/stage0-tools-bin/miri build/x86_64-unknown-linux-gnu/stage1/bin/
$ MIRI_SYSROOT=build/x86_64-unknown-linux-gnu/stage1/ build/x86_64-unknown-linux-gnu/stage1/bin/miri src/tools/miri/tests/run-pass/products.rs
Looks like RUST_SYSROOT
is not properly set during build, so I have to give the sysroot manually?
Running the test suite, however, fails:
$ CARGO_CFG_REGEX_DISABLE_AUTO_OPTIMIZATIONS=1 ./x.py --stage 0 test src/tools/miri -v
[...]
running: "/home/r/src/rust/rustc/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-j" "8" "--release" "--manifest-path" "/home/r/src/rust/rustc/src/tools/miri/Cargo.toml"
[...]
error: failed to find a `codegen-backends` folder in the sysroot candidates:
* /home/r/src/rust/rustc/build/x86_64-unknown-linux-gnu
* /home/r/src/rust/rustc/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu
* /home/r/src/rust/rustc/build/x86_64-unknown-linux-gnu/stage0-sysroot
How could we do better (other than maybe enabling std::arch
in stage 0)? @eddyb suggested that test src/tools/miri
should behave more like test src/test/run-pass
, and test the stuff produced by the previous stage, but I find that somewhat strange. The compiler itself has strange "leveling issues" in a staged build, but the tools should be more consistent.
I'd expect miri to behave more like libstd: build --stage 1 src/libstd
builds using the compiler produced in stage 0, and test --stage 1 src/libstd --no-doc
tests with that same compiler. So maybe build --stage 1 src/tools/miri
should be built with the compiler produced in stage 0 and the libstd produced in stage 1 (similar to build --stage 1 src/rustc
). build --stage 0 src/tools/miri
would use the bootstrap compiler to build miri, which will likely not work but that's okay. test --stage 1 src/tools/miri
would first do build --stage 1 src/tools/miri
and then run the tests in the stage1
sysroot.
Or does that not work because miri depends on librustc?
Cc @oli-obk @eddyb (and maybe we should get a bootstrap expert in the loop?)