Skip to content

Commit 07b89d6

Browse files
committed
Auto merge of rust-lang#104236 - compiler-errors:rollup-adjshd6, r=compiler-errors
Rollup of 9 pull requests Successful merges: - rust-lang#102763 (Some diagnostic-related nits) - rust-lang#103443 (Parser: Recover from using colon as path separator in imports) - rust-lang#103675 (remove redundent "<>" for ty::Slice with reference type) - rust-lang#104046 (bootstrap: add support for running Miri on a file) - rust-lang#104115 (Migrate crate-search element to CSS variables) - rust-lang#104190 (Ignore "Change InferCtxtBuilder from enter to build" in git blame) - rust-lang#104201 (Add check in GUI test for file loading failure) - rust-lang#104211 (:arrow_up: rust-analyzer) - rust-lang#104231 (Update mailmap) Failed merges: - rust-lang#104169 (Migrate `:target` rules to use CSS variables) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1ff5e2e + f879dac commit 07b89d6

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,10 @@ Moreover, Miri recognizes some environment variables:
433433
trigger a re-build of the standard library; you have to clear the Miri build
434434
cache manually (on Linux, `rm -rf ~/.cache/miri`).
435435
* `MIRI_SYSROOT` (recognized by `cargo miri` and the Miri driver) indicates the sysroot to use. When
436-
using `cargo miri`, only set this if you do not want to use the automatically created sysroot. For
437-
directly invoking the Miri driver, this variable (or a `--sysroot` flag) is mandatory.
436+
using `cargo miri`, this skips the automatic setup -- only set this if you do not want to use the
437+
automatically created sysroot. For directly invoking the Miri driver, this variable (or a
438+
`--sysroot` flag) is mandatory. When invoking `cargo miri setup`, this indicates where the sysroot
439+
will be put.
438440
* `MIRI_TEST_TARGET` (recognized by the test suite and the `./miri` script) indicates which target
439441
architecture to test against. `miri` and `cargo miri` accept the `--target` flag for the same
440442
purpose.

cargo-miri/src/setup.rs

+11-8
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
@@ -111,7 +114,7 @@ pub fn setup(subcommand: &MiriCommand, target: &str, rustc_version: &VersionMeta
111114
(command, rustflags)
112115
};
113116
// Make sure all target-level Miri invocations know their sysroot.
114-
std::env::set_var("MIRI_SYSROOT", sysroot_dir);
117+
std::env::set_var("MIRI_SYSROOT", &sysroot_dir);
115118

116119
// Do the build.
117120
if only_setup {
@@ -121,7 +124,7 @@ pub fn setup(subcommand: &MiriCommand, target: &str, rustc_version: &VersionMeta
121124
// We want to be quiet, but still let the user know that something is happening.
122125
eprint!("Preparing a sysroot for Miri (target: {target})... ");
123126
}
124-
Sysroot::new(sysroot_dir, target)
127+
Sysroot::new(&sysroot_dir, target)
125128
.build_from_source(&rust_src, BuildMode::Check, sysroot_config, rustc_version, cargo_cmd)
126129
.unwrap_or_else(|_| {
127130
if only_setup {

0 commit comments

Comments
 (0)