Auto merge of #141116 - RalfJung:miri-sync, r=RalfJung
Miri subtree update r? `@ghost`
This commit is contained in:
commit
2c12b4a690
23 changed files with 73 additions and 115 deletions
|
|
@ -6,7 +6,7 @@ name = "miri"
|
|||
repository = "https://github.com/rust-lang/miri"
|
||||
version = "0.1.0"
|
||||
default-run = "miri"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
|
||||
[lib]
|
||||
test = true # we have unit tests
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ license = "MIT OR Apache-2.0"
|
|||
name = "cargo-miri"
|
||||
repository = "https://github.com/rust-lang/miri"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
|
||||
[[bin]]
|
||||
name = "cargo-miri"
|
||||
|
|
|
|||
|
|
@ -63,27 +63,37 @@ fn main() {
|
|||
return;
|
||||
}
|
||||
|
||||
// The way rustdoc invokes rustc is indistinguishable from the way cargo invokes rustdoc by the
|
||||
// arguments alone. `phase_cargo_rustdoc` sets this environment variable to let us disambiguate.
|
||||
if env::var_os("MIRI_CALLED_FROM_RUSTDOC").is_some() {
|
||||
// ...however, we then also see this variable when rustdoc invokes us as the testrunner!
|
||||
// The runner is invoked as `$runtool ($runtool-arg)* output_file`;
|
||||
// since we don't specify any runtool-args, and rustdoc supplies multiple arguments to
|
||||
// the test-builder unconditionally, we can just check the number of remaining arguments:
|
||||
if args.len() == 1 {
|
||||
phase_runner(args, RunnerPhase::Rustdoc);
|
||||
} else {
|
||||
phase_rustc(args, RustcPhase::Rustdoc);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let Some(first) = args.next() else {
|
||||
show_error!(
|
||||
"`cargo-miri` called without first argument; please only invoke this binary through `cargo miri`"
|
||||
)
|
||||
};
|
||||
|
||||
// The way rustdoc invokes rustc is indistinguishable from the way cargo invokes rustdoc by the
|
||||
// arguments alone. `phase_cargo_rustdoc` sets this environment variable to let us disambiguate.
|
||||
if env::var_os("MIRI_CALLED_FROM_RUSTDOC").is_some() {
|
||||
// ...however, we then also see this variable when rustdoc invokes us as the testrunner!
|
||||
// In that case the first argument is `runner` and there are no more arguments.
|
||||
match first.as_str() {
|
||||
"runner" => phase_runner(args, RunnerPhase::Rustdoc),
|
||||
flag if flag.starts_with("--") || flag.starts_with("@") => {
|
||||
// This is probably rustdoc invoking us to build the test. But we need to get `first`
|
||||
// "back onto the iterator", it is some part of the rustc invocation.
|
||||
phase_rustc(iter::once(first).chain(args), RustcPhase::Rustdoc);
|
||||
}
|
||||
_ => {
|
||||
show_error!(
|
||||
"`cargo-miri` failed to recognize which phase of the build process this is, please report a bug.\n\
|
||||
We are inside MIRI_CALLED_FROM_RUSTDOC.\n\
|
||||
The command-line arguments were: {:#?}",
|
||||
Vec::from_iter(env::args()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
match first.as_str() {
|
||||
"miri" => phase_cargo_miri(args),
|
||||
"runner" => phase_runner(args, RunnerPhase::Cargo),
|
||||
|
|
|
|||
|
|
@ -176,6 +176,8 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
|
|||
// Set `--target-dir` to `miri` inside the original target directory.
|
||||
let target_dir = get_target_dir(&metadata);
|
||||
cmd.arg("--target-dir").arg(target_dir);
|
||||
// Enable cross-target doctests (for consistency between different cargo versions).
|
||||
cmd.arg("-Zdoctest-xcompile");
|
||||
|
||||
// *After* we set all the flags that need setting, forward everything else. Make sure to skip
|
||||
// `--target-dir` (which would otherwise be set twice).
|
||||
|
|
@ -666,11 +668,6 @@ pub fn phase_rustdoc(mut args: impl Iterator<Item = String>) {
|
|||
if arg == "--extern" {
|
||||
// Patch --extern arguments to use *.rmeta files, since phase_cargo_rustc only creates stub *.rlib files.
|
||||
forward_patched_extern_arg(&mut args, &mut cmd);
|
||||
} else if arg == "--test-runtool" {
|
||||
// An existing --test-runtool flag indicates cargo is running in cross-target mode, which we don't support.
|
||||
// Note that this is only passed when cargo is run with the unstable -Zdoctest-xcompile flag;
|
||||
// otherwise, we won't be called as rustdoc at all.
|
||||
show_error!("cross-interpreting doctests is not currently supported by Miri.");
|
||||
} else {
|
||||
cmd.arg(arg);
|
||||
}
|
||||
|
|
@ -702,10 +699,10 @@ pub fn phase_rustdoc(mut args: impl Iterator<Item = String>) {
|
|||
// make sure the 'miri' flag is set for rustdoc
|
||||
cmd.arg("--cfg").arg("miri");
|
||||
|
||||
// Make rustdoc call us back.
|
||||
// Make rustdoc call us back for the build.
|
||||
// (cargo already sets `--test-runtool` to us since we are the cargo test runner.)
|
||||
let cargo_miri_path = env::current_exe().expect("current executable path invalid");
|
||||
cmd.arg("--test-builder").arg(&cargo_miri_path); // invoked by forwarding most arguments
|
||||
cmd.arg("--test-runtool").arg(&cargo_miri_path); // invoked with just a single path argument
|
||||
|
||||
debug_cmd("[cargo-miri rustdoc]", verbose, &cmd);
|
||||
exec(cmd)
|
||||
|
|
|
|||
|
|
@ -24,11 +24,9 @@ pub fn setup(
|
|||
let ask_user = !only_setup;
|
||||
let print_sysroot = only_setup && has_arg_flag("--print-sysroot"); // whether we just print the sysroot path
|
||||
let show_setup = only_setup && !print_sysroot;
|
||||
if !only_setup {
|
||||
if let Some(sysroot) = std::env::var_os("MIRI_SYSROOT") {
|
||||
// Skip setup step if MIRI_SYSROOT is explicitly set, *unless* we are `cargo miri setup`.
|
||||
return sysroot.into();
|
||||
}
|
||||
if !only_setup && let Some(sysroot) = std::env::var_os("MIRI_SYSROOT") {
|
||||
// Skip setup step if MIRI_SYSROOT is explicitly set, *unless* we are `cargo miri setup`.
|
||||
return sysroot.into();
|
||||
}
|
||||
|
||||
// Determine where the rust sources are located. The env var trumps auto-detection.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ name = "miri-script"
|
|||
repository = "https://github.com/rust-lang/miri"
|
||||
version = "0.1.0"
|
||||
default-run = "miri-script"
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
|
||||
[workspace]
|
||||
# We make this a workspace root so that cargo does not go looking in ../Cargo.toml for the workspace root.
|
||||
|
|
|
|||
|
|
@ -675,11 +675,9 @@ impl Command {
|
|||
let mut early_flags = Vec::<OsString>::new();
|
||||
|
||||
// In `dep` mode, the target is already passed via `MIRI_TEST_TARGET`
|
||||
if !dep {
|
||||
if let Some(target) = &target {
|
||||
early_flags.push("--target".into());
|
||||
early_flags.push(target.into());
|
||||
}
|
||||
if !dep && let Some(target) = &target {
|
||||
early_flags.push("--target".into());
|
||||
early_flags.push(target.into());
|
||||
}
|
||||
early_flags.push("--edition".into());
|
||||
early_flags.push(edition.as_deref().unwrap_or("2021").into());
|
||||
|
|
@ -707,10 +705,8 @@ impl Command {
|
|||
// Add Miri flags
|
||||
let mut cmd = cmd.args(&miri_flags).args(&early_flags).args(&flags);
|
||||
// For `--dep` we also need to set the target in the env var.
|
||||
if dep {
|
||||
if let Some(target) = &target {
|
||||
cmd = cmd.env("MIRI_TEST_TARGET", target);
|
||||
}
|
||||
if dep && let Some(target) = &target {
|
||||
cmd = cmd.env("MIRI_TEST_TARGET", target);
|
||||
}
|
||||
// Finally, run the thing.
|
||||
Ok(cmd.run()?)
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ impl MiriEnv {
|
|||
let toolchain = &self.toolchain;
|
||||
let mut cmd = cmd!(
|
||||
self.sh,
|
||||
"rustfmt +{toolchain} --edition=2021 --config-path {config_path} --unstable-features --skip-children {flags...}"
|
||||
"rustfmt +{toolchain} --edition=2024 --config-path {config_path} --unstable-features --skip-children {flags...}"
|
||||
);
|
||||
if first {
|
||||
// Log an abbreviating command, and only once.
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
2ad5f8607d0e192b60b130e5cc416b477b351c18
|
||||
a69bc17fb8026bdc0d24bb1896ff95f0eba1da4e
|
||||
|
|
|
|||
|
|
@ -459,7 +459,7 @@ fn jemalloc_magic() {
|
|||
// linking, so we need to explicitly depend on the function.
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
extern "C" {
|
||||
unsafe extern "C" {
|
||||
fn _rjem_je_zone_register();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ impl NodeDebugInfo {
|
|||
/// Add a name to the tag. If a same tag is associated to several pointers,
|
||||
/// it can have several names which will be separated by commas.
|
||||
pub fn add_name(&mut self, name: &str) {
|
||||
if let Some(ref mut prev_name) = &mut self.name {
|
||||
if let Some(prev_name) = &mut self.name {
|
||||
prev_name.push_str(", ");
|
||||
prev_name.push_str(name);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -648,8 +648,7 @@ impl<'tcx> MiriMachine<'tcx> {
|
|||
AccessedAlloc(AllocId(id), access_kind) =>
|
||||
format!("{access_kind} to allocation with id {id}"),
|
||||
FreedAlloc(AllocId(id)) => format!("freed allocation with id {id}"),
|
||||
RejectedIsolatedOp(ref op) =>
|
||||
format!("{op} was made to return an error due to isolation"),
|
||||
RejectedIsolatedOp(op) => format!("{op} was made to return an error due to isolation"),
|
||||
ProgressReport { .. } =>
|
||||
format!("progress report: current operation being executed is here"),
|
||||
Int2Ptr { .. } => format!("integer-to-pointer cast"),
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
#![feature(variant_count)]
|
||||
#![feature(yeet_expr)]
|
||||
#![feature(nonzero_ops)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(strict_overflow_ops)]
|
||||
#![feature(pointer_is_aligned_to)]
|
||||
#![feature(unqualified_local_imports)]
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
// Now we make a function call, and pass `data` as first and only argument.
|
||||
let f_instance = this.get_ptr_fn(try_fn)?.as_instance()?;
|
||||
trace!("try_fn: {:?}", f_instance);
|
||||
#[allow(clippy::cloned_ref_to_slice_refs)] // the code is clearer as-is
|
||||
this.call_function(
|
||||
f_instance,
|
||||
ExternAbi::Rust,
|
||||
|
|
|
|||
|
|
@ -142,24 +142,19 @@ def test_cargo_miri_run():
|
|||
)
|
||||
|
||||
def test_cargo_miri_test():
|
||||
# rustdoc is not run on foreign targets
|
||||
is_foreign = ARGS.target is not None
|
||||
default_ref = "test.cross-target.stdout.ref" if is_foreign else "test.default.stdout.ref"
|
||||
filter_ref = "test.filter.cross-target.stdout.ref" if is_foreign else "test.filter.stdout.ref"
|
||||
|
||||
test("`cargo miri test`",
|
||||
cargo_miri("test"),
|
||||
default_ref, "test.empty.ref",
|
||||
"test.default.stdout.ref", "test.empty.ref",
|
||||
env={'MIRIFLAGS': "-Zmiri-seed=4242"},
|
||||
)
|
||||
test("`cargo miri test` (no isolation, no doctests)",
|
||||
cargo_miri("test") + ["--bins", "--tests"], # no `--lib`, we disabled that in `Cargo.toml`
|
||||
"test.cross-target.stdout.ref", "test.empty.ref",
|
||||
"test.no-doc.stdout.ref", "test.empty.ref",
|
||||
env={'MIRIFLAGS': "-Zmiri-disable-isolation"},
|
||||
)
|
||||
test("`cargo miri test` (with filter)",
|
||||
cargo_miri("test") + ["--", "--format=pretty", "pl"],
|
||||
filter_ref, "test.empty.ref",
|
||||
"test.filter.stdout.ref", "test.empty.ref",
|
||||
)
|
||||
test("`cargo miri test` (test target)",
|
||||
cargo_miri("test") + ["--test", "test", "--", "--format=pretty"],
|
||||
|
|
@ -171,7 +166,7 @@ def test_cargo_miri_test():
|
|||
)
|
||||
test("`cargo miri t` (subcrate, no isolation)",
|
||||
cargo_miri("t") + ["-p", "subcrate"],
|
||||
"test.subcrate.cross-target.stdout.ref" if is_foreign else "test.subcrate.stdout.ref",
|
||||
"test.subcrate.stdout.ref",
|
||||
"test.empty.ref",
|
||||
env={'MIRIFLAGS': "-Zmiri-disable-isolation"},
|
||||
)
|
||||
|
|
@ -181,12 +176,12 @@ def test_cargo_miri_test():
|
|||
)
|
||||
test("`cargo miri test` (custom target dir)",
|
||||
cargo_miri("test") + ["--target-dir=custom-test"],
|
||||
default_ref, "test.empty.ref",
|
||||
"test.default.stdout.ref", "test.empty.ref",
|
||||
)
|
||||
del os.environ["CARGO_TARGET_DIR"] # this overrides `build.target-dir` passed by `--config`, so unset it
|
||||
test("`cargo miri test` (config-cli)",
|
||||
cargo_miri("test") + ["--config=build.target-dir=\"config-cli\""],
|
||||
default_ref, "test.empty.ref",
|
||||
"test.default.stdout.ref", "test.empty.ref",
|
||||
)
|
||||
if ARGS.multi_target:
|
||||
test_cargo_miri_multi_target()
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
|
||||
running 0 tests
|
||||
|
||||
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out; finished in $TIME
|
||||
|
||||
imported main
|
||||
|
||||
running 1 test
|
||||
test simple ... ok
|
||||
|
||||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 5 filtered out; finished in $TIME
|
||||
|
||||
|
|
@ -20,3 +20,13 @@ running 6 tests
|
|||
...i..
|
||||
test result: ok. 5 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in $TIME
|
||||
|
||||
|
||||
running 5 tests
|
||||
.....
|
||||
test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
|
||||
|
||||
|
||||
running 5 tests
|
||||
.....
|
||||
test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
running 0 tests
|
||||
|
||||
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
|
||||
|
||||
|
||||
running 0 tests
|
||||
|
||||
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
|
||||
|
||||
subcrate testing
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
error: Undefined Behavior: Race condition detected between (1) 4-byte atomic store on thread `unnamed-ID` and (2) 2-byte atomic load on thread `unnamed-ID` at ALLOC. (2) just happened here
|
||||
--> tests/fail/weak_memory/racing_mixed_size.rs:LL:CC
|
||||
|
|
||||
LL | std::intrinsics::atomic_load_relaxed(hi);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Race condition detected between (1) 4-byte atomic store on thread `unnamed-ID` and (2) 2-byte atomic load on thread `unnamed-ID` at ALLOC. (2) just happened here
|
||||
|
|
||||
help: and (1) occurred earlier here
|
||||
--> tests/fail/weak_memory/racing_mixed_size.rs:LL:CC
|
||||
|
|
||||
LL | x.store(1, Relaxed);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
= help: overlapping unsynchronized atomic accesses must use the same access size
|
||||
= help: see https://doc.rust-lang.org/nightly/std/sync/atomic/index.html#memory-model-for-atomic-accesses for more information about the Rust memory model
|
||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
||||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||
= note: BACKTRACE (of the first span) on thread `unnamed-ID`:
|
||||
= note: inside closure at tests/fail/weak_memory/racing_mixed_size.rs:LL:CC
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
@ -12,7 +12,6 @@ fn main() {
|
|||
mut_raw_mut();
|
||||
partially_invalidate_mut();
|
||||
drop_after_sharing();
|
||||
// direct_mut_to_const_raw();
|
||||
two_raw();
|
||||
shr_and_raw();
|
||||
disjoint_mutable_subborrows();
|
||||
|
|
|
|||
|
|
@ -183,18 +183,18 @@ fn basic() {
|
|||
|
||||
fn smoke_resume_arg() {
|
||||
fn drain<G: Coroutine<R, Yield = Y> + Unpin, R, Y>(
|
||||
gen: &mut G,
|
||||
gen_: &mut G,
|
||||
inout: Vec<(R, CoroutineState<Y, G::Return>)>,
|
||||
) where
|
||||
Y: Debug + PartialEq,
|
||||
G::Return: Debug + PartialEq,
|
||||
{
|
||||
let mut gen = Pin::new(gen);
|
||||
let mut gen_ = Pin::new(gen_);
|
||||
|
||||
for (input, out) in inout {
|
||||
assert_eq!(gen.as_mut().resume(input), out);
|
||||
assert_eq!(gen_.as_mut().resume(input), out);
|
||||
// Test if the coroutine is valid (according to type invariants).
|
||||
let _ = unsafe { ManuallyDrop::new(ptr::read(gen.as_mut().get_unchecked_mut())) };
|
||||
let _ = unsafe { ManuallyDrop::new(ptr::read(gen_.as_mut().get_unchecked_mut())) };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,8 +44,7 @@ pub fn flagsplit(flags: &str) -> Vec<String> {
|
|||
fn build_native_lib() -> PathBuf {
|
||||
let cc = env::var("CC").unwrap_or_else(|_| "cc".into());
|
||||
// Target directory that we can write to.
|
||||
let so_target_dir =
|
||||
Path::new(&env::var_os("CARGO_TARGET_DIR").unwrap()).join("miri-native-lib");
|
||||
let so_target_dir = Path::new(env!("CARGO_TARGET_TMPDIR")).join("miri-native-lib");
|
||||
// Create the directory if it does not already exist.
|
||||
std::fs::create_dir_all(&so_target_dir)
|
||||
.expect("Failed to create directory for shared object file");
|
||||
|
|
@ -101,7 +100,7 @@ fn miri_config(
|
|||
let mut config = Config {
|
||||
target: Some(target.to_owned()),
|
||||
program,
|
||||
out_dir: PathBuf::from(std::env::var_os("CARGO_TARGET_DIR").unwrap()).join("miri_ui"),
|
||||
out_dir: PathBuf::from(env!("CARGO_TARGET_TMPDIR")).join("miri_ui"),
|
||||
threads: std::env::var("MIRI_TEST_THREADS")
|
||||
.ok()
|
||||
.map(|threads| NonZero::new(threads.parse().unwrap()).unwrap()),
|
||||
|
|
@ -319,10 +318,10 @@ fn main() -> Result<()> {
|
|||
let mut args = std::env::args_os();
|
||||
|
||||
// Skip the program name and check whether this is a `./miri run-dep` invocation
|
||||
if let Some(first) = args.nth(1) {
|
||||
if first == "--miri-run-dep-mode" {
|
||||
return run_dep_mode(target, args);
|
||||
}
|
||||
if let Some(first) = args.nth(1)
|
||||
&& first == "--miri-run-dep-mode"
|
||||
{
|
||||
return run_dep_mode(target, args);
|
||||
}
|
||||
|
||||
ui(Mode::Pass, "tests/pass", &target, WithoutDependencies, tmpdir.path())?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue