must point to the `library` subdirectory of a `rust-lang/rust` repository
checkout. Note that changing files in that directory does not automatically
trigger a re-build of the standard library; you have to clear the Miri build
- cache manually (on Linux, `rm -rf ~/.cache/miri`).
+ cache manually (on Linux, `rm -rf ~/.cache/miri`;
+ on Windows, `rmdir /S "%LOCALAPPDATA%\rust-lang\miri\cache"`;
+ and on macOS, `rm -rf ~/Library/Caches/org.rust-lang.miri`).
* `MIRI_SYSROOT` (recognized by `cargo miri` and the Miri driver) indicates the sysroot to use. When
- using `cargo miri`, only set this if you do not want to use the automatically created sysroot. For
- directly invoking the Miri driver, this variable (or a `--sysroot` flag) is mandatory.
+ using `cargo miri`, this skips the automatic setup -- only set this if you do not want to use the
+ automatically created sysroot. For directly invoking the Miri driver, this variable (or a
+ `--sysroot` flag) is mandatory. When invoking `cargo miri setup`, this indicates where the sysroot
+ will be put.
* `MIRI_TEST_TARGET` (recognized by the test suite and the `./miri` script) indicates which target
architecture to test against. `miri` and `cargo miri` accept the `--target` flag for the same
purpose.
command.stdout(process::Stdio::null());
command.stderr(process::Stdio::null());
}
- // Disable debug assertions in the standard library -- Miri is already slow enough.
- // But keep the overflow checks, they are cheap. This completely overwrites flags
- // the user might have set, which is consistent with normal `cargo build` that does
- // not apply `RUSTFLAGS` to the sysroot either.
- let rustflags = vec!["-Cdebug-assertions=off".into(), "-Coverflow-checks=on".into()];
- (command, rustflags)
+
+ command
};
+ // Disable debug assertions in the standard library -- Miri is already slow enough.
+ // But keep the overflow checks, they are cheap. This completely overwrites flags
+ // the user might have set, which is consistent with normal `cargo build` that does
+ // not apply `RUSTFLAGS` to the sysroot either.
+ let rustflags = &["-Cdebug-assertions=off", "-Coverflow-checks=on"];
// Make sure all target-level Miri invocations know their sysroot.
- std::env::set_var("MIRI_SYSROOT", sysroot_dir);
+ std::env::set_var("MIRI_SYSROOT", &sysroot_dir);
// Do the build.
if only_setup {
// We want to be quiet, but still let the user know that something is happening.
eprint!("Preparing a sysroot for Miri (target: {target})... ");
}
- SysrootBuilder::new(sysroot_dir, target)
- Sysroot::new(&sysroot_dir, target)
- .build_from_source(&rust_src, BuildMode::Check, sysroot_config, rustc_version, cargo_cmd)
++ SysrootBuilder::new(&sysroot_dir, target)
+ .build_mode(BuildMode::Check)
+ .rustc_version(rustc_version.clone())
+ .sysroot_config(sysroot_config)
+ .rustflags(rustflags)
+ .cargo(cargo_cmd)
+ .build_from_source(&rust_src)
.unwrap_or_else(|_| {
if only_setup {
show_error!("failed to build sysroot, see error details above")