Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miri subtree update #122246

Merged
merged 45 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
81fed2f
remove some flags that haven't had an effect in a while
RalfJung Mar 2, 2024
c1a5906
remove the ability to disable ABI checking
RalfJung Mar 2, 2024
32643dc
Fix .\miri fmt on Windows
RossSmyth Feb 26, 2024
cfc10f0
fix MIRI_LOG=info not setting the level for miri itself
RalfJung Mar 3, 2024
3041c78
log when we change the active thread
RalfJung Mar 3, 2024
983c2c5
do not rely on tracing's scope exit logging, it is wrong
RalfJung Mar 3, 2024
f51f923
Auto merge of #3348 - RalfJung:miri-thread-logging, r=RalfJung
bors Mar 3, 2024
83e2e2d
nits and typos
RalfJung Mar 3, 2024
f47732b
Auto merge of #3330 - RossSmyth:win-fmt, r=RalfJung
bors Mar 3, 2024
fbafd36
disable diagnostic deduplication
RalfJung Mar 3, 2024
d5f31bd
implement manual deduplication for isolation-error=warn-nobacktrace
RalfJung Mar 4, 2024
f70feaf
linux-futex test: add comment
RalfJung Mar 4, 2024
ede97c6
Auto merge of #3339 - RalfJung:remove-old-flags, r=saethlin
bors Mar 4, 2024
e87f825
Auto merge of #3351 - RalfJung:diagnostic-dedup-considered-harmful, r…
bors Mar 4, 2024
974446e
we properly rebuild the cache now when MIRI_LIB_SRC contents change
RalfJung Mar 4, 2024
8851f3c
Auto merge of #3354 - RalfJung:MIRI_LIB_SRC-change, r=RalfJung
bors Mar 4, 2024
75f6694
Use cargo miri clean in build-all-targets.sh
saethlin Mar 4, 2024
5b05be1
Auto merge of #3355 - saethlin:cargo-miri-clean, r=RalfJung
bors Mar 4, 2024
a477cf4
Conjob → Cronjob
RalfJung Mar 4, 2024
45d955e
reorder rustc crate imports a bit
RalfJung Mar 2, 2024
4fdb215
Auto merge of #3356 - RalfJung:typo, r=RalfJung
bors Mar 4, 2024
790287a
Auto merge of #3357 - RalfJung:imports, r=RalfJung
bors Mar 4, 2024
2b40181
give macOS even more time to sleep
RalfJung Mar 4, 2024
65ec028
Auto merge of #3358 - RalfJung:zzz, r=RalfJung
bors Mar 4, 2024
5294dd8
Bump mio from 0.8.10 to 0.8.11 in /test_dependencies
dependabot[bot] Mar 4, 2024
e88704e
Auto merge of #3359 - rust-lang:dependabot/cargo/test_dependencies/mi…
bors Mar 4, 2024
033c1e0
Auto merge of #3340 - RalfJung:no-disable-abi-check, r=oli-obk
bors Mar 6, 2024
4b955f1
Preparing for merge from rustc
RalfJung Mar 6, 2024
a5a8437
Merge from rustc
RalfJung Mar 6, 2024
3c2318c
make remaining FloatTy matches exhaustive
RalfJung Mar 6, 2024
305d2b0
Auto merge of #3363 - RalfJung:rustup, r=RalfJung
bors Mar 6, 2024
c301bf9
Preparing for merge from rustc
Mar 8, 2024
2ebf9ec
Merge from rustc
Mar 8, 2024
fcd2efe
fix clippy lints
RalfJung Mar 8, 2024
4db028f
Auto merge of #3365 - rust-lang:rustup-2024-03-08, r=RalfJung
bors Mar 8, 2024
4235ec5
compiletest: create fresh tempdir for tests to use
RalfJung Mar 8, 2024
52db5f6
Preparing for merge from rustc
Mar 9, 2024
e720147
Merge from rustc
Mar 9, 2024
91644dd
fmt
Mar 9, 2024
cabac98
Auto merge of #3366 - RalfJung:tempdir, r=oli-obk
bors Mar 9, 2024
00be352
rename tests/compiletest → tests/ui
RalfJung Mar 9, 2024
b0fad9a
Auto merge of #3368 - RalfJung:ui, r=RalfJung
bors Mar 9, 2024
862f918
fix clippy lints
RalfJung Mar 9, 2024
0ebb78f
Auto merge of #3367 - rust-lang:rustup-2024-03-09, r=RalfJung
bors Mar 9, 2024
9a308d4
update lockfile
RalfJung Mar 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2493,6 +2493,7 @@ dependencies = [
"regex",
"rustc_version",
"smallvec",
"tempfile",
"ui_test 0.21.2",
]

Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ jobs:
run: RUSTFLAGS="--cap-lints warn" cargo +stable install josh-proxy --git https://github.com/josh-project/josh --tag r22.12.06
- name: setup bot git name and email
run: |
git config --global user.name 'The Miri Conjob Bot'
git config --global user.name 'The Miri Cronjob Bot'
git config --global user.email 'miri@cron.bot'
- name: get changes from rustc
run: ./miri rustc-pull
Expand Down
1 change: 1 addition & 0 deletions src/tools/miri/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ dependencies = [
"regex",
"rustc_version",
"smallvec",
"tempfile",
"ui_test",
]

Expand Down
3 changes: 2 additions & 1 deletion src/tools/miri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ ui_test = "0.21.1"
rustc_version = "0.4"
regex = "1.5.5"
lazy_static = "1.4.0"
tempfile = "3"

[package.metadata.rust-analyzer]
# This crate uses #[feature(rustc_private)].
# See https://github.com/rust-analyzer/rust-analyzer/pull/7891
rustc_private = true

[[test]]
name = "compiletest"
name = "ui"
harness = false

[features]
Expand Down
12 changes: 3 additions & 9 deletions src/tools/miri/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ environment variable. We first document the most relevant and most commonly used
and `warn-nobacktrace` are the supported actions. The default is to `abort`,
which halts the machine. Some (but not all) operations also support continuing
execution with a "permission denied" error being returned to the program.
`warn` prints a full backtrace when that happens; `warn-nobacktrace` is less
verbose. `hide` hides the warning entirely.
`warn` prints a full backtrace each time that happens; `warn-nobacktrace` is less
verbose and shown at most once per operation. `hide` hides the warning entirely.
* `-Zmiri-num-cpus` states the number of available CPUs to be reported by miri. By default, the
number of available CPUs is `1`. Note that this flag does not affect how miri handles threads in
any way.
Expand Down Expand Up @@ -359,8 +359,6 @@ The remaining flags are for advanced use only, and more likely to change or be r
Some of these are **unsound**, which means they can lead
to Miri failing to detect cases of undefined behavior in a program.

* `-Zmiri-disable-abi-check` disables checking [function ABI]. Using this flag
is **unsound**. This flag is **deprecated**.
* `-Zmiri-disable-alignment-check` disables checking pointer alignment, so you
can focus on other failures, but it means Miri can miss bugs in your program.
Using this flag is **unsound**.
Expand Down Expand Up @@ -465,11 +463,7 @@ Moreover, Miri recognizes some environment variables:
* `MIRI_LIB_SRC` defines the directory where Miri expects the sources of the
standard library that it will build and use for interpretation. This directory
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 with `cargo miri clean` or deleting it 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`).
checkout.
* `MIRI_SYSROOT` (recognized by `cargo miri` and the Miri driver) indicates the sysroot to use. When
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
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/ci/build-all-targets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ PLATFORM_SUPPORT_FILE=$(rustc +miri --print sysroot)/share/doc/rust/html/rustc/p

for target in $(python3 ci/scrape-targets.py $PLATFORM_SUPPORT_FILE); do
# Wipe the cache before every build to minimize disk usage
rm -rf ~/.cache/miri
cargo +miri miri clean
if cargo +miri miri setup --target $target 2>&1 | tee failures/$target; then
# If the build succeeds, delete its output. If we have output, a build failed.
rm $FAILS_DIR/$target
Expand Down
50 changes: 20 additions & 30 deletions src/tools/miri/miri-script/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,11 @@ impl Command {
let miri_flags = flagsplit(&miri_flags);
let toolchain = &e.toolchain;
let extra_flags = &e.cargo_extra_flags;
let edition_flags = (!have_edition).then_some("--edition=2021"); // keep in sync with `compiletest.rs`.`
let edition_flags = (!have_edition).then_some("--edition=2021"); // keep in sync with `tests/ui.rs`.`
if dep {
cmd!(
e.sh,
"cargo +{toolchain} --quiet test --test compiletest {extra_flags...} --manifest-path {miri_manifest} -- --miri-run-dep-mode {miri_flags...} {edition_flags...} {flags...}"
"cargo +{toolchain} --quiet test {extra_flags...} --manifest-path {miri_manifest} --test ui -- --miri-run-dep-mode {miri_flags...} {edition_flags...} {flags...}"
).quiet().run()?;
} else {
cmd!(
Expand All @@ -526,37 +526,27 @@ impl Command {
}

fn fmt(flags: Vec<OsString>) -> Result<()> {
use itertools::Itertools;

let e = MiriEnv::new()?;
let toolchain = &e.toolchain;
let config_path = path!(e.miri_dir / "rustfmt.toml");

let mut cmd = cmd!(
e.sh,
"rustfmt +{toolchain} --edition=2021 --config-path {config_path} --unstable-features --skip-children {flags...}"
);
eprintln!("$ {cmd} ...");

// Add all the filenames to the command.
// FIXME: `rustfmt` will follow the `mod` statements in these files, so we get a bunch of
// duplicate diffs.
for item in WalkDir::new(&e.miri_dir).into_iter().filter_entry(|entry| {
let name = entry.file_name().to_string_lossy();
let ty = entry.file_type();
if ty.is_file() {
name.ends_with(".rs")
} else {
// dir or symlink. skip `target` and `.git`.
&name != "target" && &name != ".git"
}
}) {
let item = item?;
if item.file_type().is_file() {
cmd = cmd.arg(item.into_path());
}
}
// Collect each rust file in the miri repo.
let files = WalkDir::new(&e.miri_dir)
.into_iter()
.filter_entry(|entry| {
let name = entry.file_name().to_string_lossy();
let ty = entry.file_type();
if ty.is_file() {
name.ends_with(".rs")
} else {
// dir or symlink. skip `target` and `.git`.
&name != "target" && &name != ".git"
}
})
.filter_ok(|item| item.file_type().is_file())
.map_ok(|item| item.into_path());

// We want our own error message, repeating the command is too much.
cmd.quiet().run().map_err(|_| anyhow!("`rustfmt` failed"))?;
Ok(())
e.format_files(files, &e.toolchain[..], &config_path, &flags[..])
}
}
48 changes: 46 additions & 2 deletions src/tools/miri/miri-script/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::ffi::{OsStr, OsString};
use std::path::PathBuf;
use std::path::{Path, PathBuf};

use anyhow::{Context, Result};
use anyhow::{anyhow, Context, Result};
use dunce::canonicalize;
use path_macro::path;
use xshell::{cmd, Shell};
Expand Down Expand Up @@ -145,4 +145,48 @@ impl MiriEnv {
.run()?;
Ok(())
}

/// Receives an iterator of files.
/// Will format each file with the miri rustfmt config.
/// Does not recursively format modules.
pub fn format_files(
&self,
files: impl Iterator<Item = Result<PathBuf, walkdir::Error>>,
toolchain: &str,
config_path: &Path,
flags: &[OsString],
) -> anyhow::Result<()> {
use itertools::Itertools;

let mut first = true;

// Format in batches as not all our files fit into Windows' command argument limit.
for batch in &files.chunks(256) {
// Build base command.
let mut cmd = cmd!(
self.sh,
"rustfmt +{toolchain} --edition=2021 --config-path {config_path} --unstable-features --skip-children {flags...}"
);
if first {
// Log an abbreviating command, and only once.
eprintln!("$ {cmd} ...");
first = false;
}
// Add files.
for file in batch {
// Make it a relative path so that on platforms with extremely tight argument
// limits (like Windows), we become immune to someone cloning the repo
// 50 directories deep.
let file = file?;
let file = file.strip_prefix(&self.miri_dir)?;
cmd = cmd.arg(file);
}

// Run rustfmt.
// We want our own error message, repeating the command is too much.
cmd.quiet().run().map_err(|_| anyhow!("`rustfmt` failed"))?;
}

Ok(())
}
}
2 changes: 1 addition & 1 deletion src/tools/miri/rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1a1876c9790f168fb51afa335a7ba3e6fc267d75
4d4bb491b65c300835442f6cb4f34fc9a5685c26
32 changes: 10 additions & 22 deletions src/tools/miri/src/bin/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
rustc::untranslatable_diagnostic
)]

// Some "regular" crates we want to share with rustc
#[macro_use]
extern crate tracing;

// The rustc crates we need
extern crate rustc_data_structures;
extern crate rustc_driver;
extern crate rustc_hir;
Expand All @@ -16,8 +21,6 @@ extern crate rustc_log;
extern crate rustc_metadata;
extern crate rustc_middle;
extern crate rustc_session;
#[macro_use]
extern crate tracing;

use std::env::{self, VarError};
use std::num::NonZero;
Expand Down Expand Up @@ -202,16 +205,12 @@ fn rustc_logger_config() -> rustc_log::LoggerConfig {
// rustc traced, but you can also do `MIRI_LOG=miri=trace,rustc_const_eval::interpret=debug`.
if tracing::Level::from_str(&var).is_ok() {
cfg.filter = Ok(format!(
"rustc_middle::mir::interpret={var},rustc_const_eval::interpret={var}"
"rustc_middle::mir::interpret={var},rustc_const_eval::interpret={var},miri={var}"
));
} else {
cfg.filter = Ok(var);
}
}
// Enable verbose entry/exit logging by default if MIRI_LOG is set.
if matches!(cfg.verbose_entry_exit, Err(VarError::NotPresent)) {
cfg.verbose_entry_exit = Ok(format!("1"));
}
}

cfg
Expand Down Expand Up @@ -342,7 +341,8 @@ fn main() {
// (`install_ice_hook` might change `RUST_BACKTRACE`.)
let env_snapshot = env::vars_os().collect::<Vec<_>>();

let args = rustc_driver::args::raw_args(&early_dcx).unwrap_or_else(|_| std::process::exit(rustc_driver::EXIT_FAILURE));
let args = rustc_driver::args::raw_args(&early_dcx)
.unwrap_or_else(|_| std::process::exit(rustc_driver::EXIT_FAILURE));

// If the environment asks us to actually be rustc, then do that.
if let Some(crate_kind) = env::var_os("MIRI_BE_RUSTC") {
Expand Down Expand Up @@ -408,17 +408,11 @@ fn main() {
miri_config.check_alignment = miri::AlignmentCheck::None;
} else if arg == "-Zmiri-symbolic-alignment-check" {
miri_config.check_alignment = miri::AlignmentCheck::Symbolic;
} else if arg == "-Zmiri-check-number-validity" {
eprintln!(
"WARNING: the flag `-Zmiri-check-number-validity` no longer has any effect \
since it is now enabled by default"
);
} else if arg == "-Zmiri-disable-abi-check" {
eprintln!(
"WARNING: the flag `-Zmiri-disable-abi-check` is deprecated and planned to be removed.\n\
If you have a use-case for it, please file an issue."
"WARNING: the flag `-Zmiri-disable-abi-check` no longer has any effect; \
ABI checks cannot be disabled any more"
);
miri_config.check_abi = false;
} else if arg == "-Zmiri-disable-isolation" {
if matches!(isolation_enabled, Some(true)) {
show_error!(
Expand Down Expand Up @@ -459,8 +453,6 @@ fn main() {
miri_config.collect_leak_backtraces = false;
} else if arg == "-Zmiri-panic-on-unsupported" {
miri_config.panic_on_unsupported = true;
} else if arg == "-Zmiri-tag-raw-pointers" {
eprintln!("WARNING: `-Zmiri-tag-raw-pointers` has no effect; it is enabled by default");
} else if arg == "-Zmiri-strict-provenance" {
miri_config.provenance_mode = ProvenanceMode::Strict;
} else if arg == "-Zmiri-permissive-provenance" {
Expand All @@ -476,10 +468,6 @@ fn main() {
"scalar" => RetagFields::OnlyScalar,
_ => show_error!("`-Zmiri-retag-fields` can only be `all`, `none`, or `scalar`"),
};
} else if arg == "-Zmiri-track-raw-pointers" {
eprintln!(
"WARNING: `-Zmiri-track-raw-pointers` has no effect; it is enabled by default"
);
} else if let Some(param) = arg.strip_prefix("-Zmiri-seed=") {
if miri_config.seed.is_some() {
show_error!("Cannot specify -Zmiri-seed multiple times!");
Expand Down
18 changes: 13 additions & 5 deletions src/tools/miri/src/concurrency/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,13 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {

/// Set an active thread and return the id of the thread that was active before.
fn set_active_thread_id(&mut self, id: ThreadId) -> ThreadId {
let active_thread_id = self.active_thread;
self.active_thread = id;
assert!(self.active_thread.index() < self.threads.len());
active_thread_id
assert!(id.index() < self.threads.len());
info!(
"---------- Now executing on thread `{}` (previous: `{}`) ----------------------------------------",
self.get_thread_display_name(id),
self.get_thread_display_name(self.active_thread)
);
std::mem::replace(&mut self.active_thread, id)
}

/// Get the id of the currently active thread.
Expand Down Expand Up @@ -735,6 +738,11 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> {
for (id, thread) in threads {
debug_assert_ne!(self.active_thread, id);
if thread.state == ThreadState::Enabled {
info!(
"---------- Now executing on thread `{}` (previous: `{}`) ----------------------------------------",
self.get_thread_display_name(id),
self.get_thread_display_name(self.active_thread)
);
self.active_thread = id;
break;
}
Expand Down Expand Up @@ -882,7 +890,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
instance,
start_abi,
&[*func_arg],
Some(&ret_place.into()),
Some(&ret_place),
StackPopCleanup::Root { cleanup: true },
)?;

Expand Down
7 changes: 2 additions & 5 deletions src/tools/miri/src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ pub struct MiriConfig {
pub unique_is_unique: bool,
/// Controls alignment checking.
pub check_alignment: AlignmentCheck,
/// Controls function [ABI](Abi) checking.
pub check_abi: bool,
/// Action for an op requiring communication with the host.
pub isolated_op: IsolatedOp,
/// Determines if memory leaks should be ignored.
Expand Down Expand Up @@ -162,7 +160,6 @@ impl Default for MiriConfig {
borrow_tracker: Some(BorrowTrackerMethod::StackedBorrows),
unique_is_unique: false,
check_alignment: AlignmentCheck::Int,
check_abi: true,
isolated_op: IsolatedOp::Reject(RejectOpWith::Abort),
ignore_leaks: false,
forwarded_env_vars: vec![],
Expand Down Expand Up @@ -394,7 +391,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
argv,
Scalar::from_u8(sigpipe).into(),
],
Some(&ret_place.into()),
Some(&ret_place),
StackPopCleanup::Root { cleanup: true },
)?;
}
Expand All @@ -403,7 +400,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
entry_instance,
Abi::Rust,
&[argc.into(), argv],
Some(&ret_place.into()),
Some(&ret_place),
StackPopCleanup::Root { cleanup: true },
)?;
}
Expand Down
Loading
Loading