Skip to content

Commit 15e7b5a

Browse files
committed
Auto merge of #2665 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 1e8e0bd + a0f6506 commit 15e7b5a

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,10 @@ Moreover, Miri recognizes some environment variables:
436436
on Windows, `rmdir /S "%LOCALAPPDATA%\rust-lang\miri\cache"`;
437437
and on macOS, `rm -rf ~/Library/Caches/org.rust-lang.miri`).
438438
* `MIRI_SYSROOT` (recognized by `cargo miri` and the Miri driver) indicates the sysroot to use. When
439-
using `cargo miri`, only set this if you do not want to use the automatically created sysroot. For
440-
directly invoking the Miri driver, this variable (or a `--sysroot` flag) is mandatory.
439+
using `cargo miri`, this skips the automatic setup -- only set this if you do not want to use the
440+
automatically created sysroot. For directly invoking the Miri driver, this variable (or a
441+
`--sysroot` flag) is mandatory. When invoking `cargo miri setup`, this indicates where the sysroot
442+
will be put.
441443
* `MIRI_TEST_TARGET` (recognized by the test suite and the `./miri` script) indicates which target
442444
architecture to test against. `miri` and `cargo miri` accept the `--target` flag for the same
443445
purpose.

cargo-miri/src/setup.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ pub fn setup(subcommand: &MiriCommand, target: &str, rustc_version: &VersionMeta
1717
let only_setup = matches!(subcommand, MiriCommand::Setup);
1818
let ask_user = !only_setup;
1919
let print_sysroot = only_setup && has_arg_flag("--print-sysroot"); // whether we just print the sysroot path
20-
if std::env::var_os("MIRI_SYSROOT").is_some() {
21-
if only_setup {
22-
println!("WARNING: MIRI_SYSROOT already set, not doing anything.")
23-
}
20+
if !only_setup && std::env::var_os("MIRI_SYSROOT").is_some() {
21+
// Skip setup step if MIRI_SYSROOT is explicitly set, *unless* we are `cargo miri setup`.
2422
return;
2523
}
2624

@@ -61,8 +59,13 @@ pub fn setup(subcommand: &MiriCommand, target: &str, rustc_version: &VersionMeta
6159
}
6260

6361
// Determine where to put the sysroot.
64-
let user_dirs = directories::ProjectDirs::from("org", "rust-lang", "miri").unwrap();
65-
let sysroot_dir = user_dirs.cache_dir();
62+
let sysroot_dir = match std::env::var_os("MIRI_SYSROOT") {
63+
Some(dir) => PathBuf::from(dir),
64+
None => {
65+
let user_dirs = directories::ProjectDirs::from("org", "rust-lang", "miri").unwrap();
66+
user_dirs.cache_dir().to_owned()
67+
}
68+
};
6669
// Sysroot configuration and build details.
6770
let sysroot_config = if std::env::var_os("MIRI_NO_STD").is_some() {
6871
SysrootConfig::NoStd
@@ -114,7 +117,7 @@ pub fn setup(subcommand: &MiriCommand, target: &str, rustc_version: &VersionMeta
114117
// not apply `RUSTFLAGS` to the sysroot either.
115118
let rustflags = &["-Cdebug-assertions=off", "-Coverflow-checks=on"];
116119
// Make sure all target-level Miri invocations know their sysroot.
117-
std::env::set_var("MIRI_SYSROOT", sysroot_dir);
120+
std::env::set_var("MIRI_SYSROOT", &sysroot_dir);
118121

119122
// Do the build.
120123
if only_setup {
@@ -124,7 +127,7 @@ pub fn setup(subcommand: &MiriCommand, target: &str, rustc_version: &VersionMeta
124127
// We want to be quiet, but still let the user know that something is happening.
125128
eprint!("Preparing a sysroot for Miri (target: {target})... ");
126129
}
127-
SysrootBuilder::new(sysroot_dir, target)
130+
SysrootBuilder::new(&sysroot_dir, target)
128131
.build_mode(BuildMode::Check)
129132
.rustc_version(rustc_version.clone())
130133
.sysroot_config(sysroot_config)

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
11fa0850f03ae49fe1053a21bcdcf8a301668ad8
1+
101e1822c3e54e63996c8aaa014d55716f3937eb

src/stacked_borrows/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
10531053
// pointers we need to retag, so we can stop recursion early.
10541054
// This optimization is crucial for ZSTs, because they can contain way more fields
10551055
// than we can ever visit.
1056-
if !place.layout.is_unsized() && place.layout.size < self.ecx.pointer_size() {
1056+
if place.layout.is_sized() && place.layout.size < self.ecx.pointer_size() {
10571057
return Ok(());
10581058
}
10591059

0 commit comments

Comments
 (0)