Skip to content

Commit

Permalink
Auto merge of rust-lang#3340 - RalfJung:no-disable-abi-check, r=oli-obk
Browse files Browse the repository at this point in the history
remove the ability to disable ABI checking

This got deprecated in rust-lang/miri#3071, about half a year ago.

`@rust-lang/miri` I think it's fine to remove this now.
  • Loading branch information
bors committed Mar 6, 2024
2 parents e88704e + c1a5906 commit 033c1e0
Show file tree
Hide file tree
Showing 17 changed files with 11 additions and 128 deletions.
2 changes: 0 additions & 2 deletions src/tools/miri/README.md
Original file line number Diff line number Diff line change
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
5 changes: 2 additions & 3 deletions src/tools/miri/src/bin/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,9 @@ fn main() {
miri_config.check_alignment = miri::AlignmentCheck::Symbolic;
} 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
3 changes: 0 additions & 3 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
4 changes: 2 additions & 2 deletions src/tools/miri/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
let this = self.eval_context_mut();
let param_env = ty::ParamEnv::reveal_all(); // in Miri this is always the param_env we use... and this.param_env is private.
let callee_abi = f.ty(*this.tcx, param_env).fn_sig(*this.tcx).abi();
if this.machine.enforce_abi && callee_abi != caller_abi {
if callee_abi != caller_abi {
throw_ub_format!(
"calling a function with ABI {} using caller ABI {}",
callee_abi.name(),
Expand Down Expand Up @@ -956,7 +956,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {

/// Check that the ABI is what we expect.
fn check_abi<'a>(&self, abi: Abi, exp_abi: Abi) -> InterpResult<'a, ()> {
if self.eval_context_ref().machine.enforce_abi && abi != exp_abi {
if abi != exp_abi {
throw_ub_format!(
"calling a function with ABI {} using caller ABI {}",
exp_abi.name(),
Expand Down
9 changes: 2 additions & 7 deletions src/tools/miri/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,6 @@ pub struct MiriMachine<'mir, 'tcx> {
/// Whether to enforce the validity invariant.
pub(crate) validate: bool,

/// Whether to enforce [ABI](Abi) of function calls.
pub(crate) enforce_abi: bool,

/// The table of file descriptors.
pub(crate) file_handler: shims::unix::FileHandler,
/// The table of directory descriptors.
Expand Down Expand Up @@ -644,7 +641,6 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
tls: TlsData::default(),
isolated_op: config.isolated_op,
validate: config.validate,
enforce_abi: config.check_abi,
file_handler: FileHandler::new(config.mute_stdout_stderr),
dir_handler: Default::default(),
layouts,
Expand Down Expand Up @@ -787,7 +783,6 @@ impl VisitProvenance for MiriMachine<'_, '_> {
tcx: _,
isolated_op: _,
validate: _,
enforce_abi: _,
clock: _,
layouts: _,
static_roots: _,
Expand Down Expand Up @@ -935,8 +930,8 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
}

#[inline(always)]
fn enforce_abi(ecx: &MiriInterpCx<'mir, 'tcx>) -> bool {
ecx.machine.enforce_abi
fn enforce_abi(_ecx: &MiriInterpCx<'mir, 'tcx>) -> bool {
true
}

#[inline(always)]
Expand Down
29 changes: 0 additions & 29 deletions src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.rs

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ fn main() {
after_call = {
Return()
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ LL | | let _unit: ();
LL | | {
LL | | let non_copy = S(42);
... |
LL | |
LL | | }
LL | | }
| |_____^
help: <TAG> is this argument
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ LL | | let _unit: ();
LL | | {
LL | | let non_copy = S(42);
... |
LL | |
LL | | }
LL | | }
| |_____^
help: the protected tag <TAG> was created here, in the initial state Reserved
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//@compile-flags: -Zmiri-disable-abi-check
#![feature(c_unwind)]

#[no_mangle]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
WARNING: the flag `-Zmiri-disable-abi-check` is deprecated and planned to be removed.
If you have a use-case for it, please file an issue.
thread 'main' panicked at $DIR/exported_symbol_bad_unwind1.rs:LL:CC:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Expand Down
12 changes: 0 additions & 12 deletions src/tools/miri/tests/fail/panic/bad_miri_start_unwind.rs

This file was deleted.

17 changes: 0 additions & 17 deletions src/tools/miri/tests/fail/panic/bad_miri_start_unwind.stderr

This file was deleted.

3 changes: 3 additions & 0 deletions src/tools/miri/tests/fail/panic/bad_unwind.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#![feature(c_unwind)]

//! Unwinding when the caller ABI is "C" (without "-unwind") is UB.
// The opposite version (callee does not allow unwinding) is impossible to
// even write: MIR validation catches functions that have `UnwindContinue` but
// are not allowed to unwind.

extern "C-unwind" fn unwind() {
panic!();
Expand Down
24 changes: 0 additions & 24 deletions src/tools/miri/tests/pass/function_calls/disable_abi_check.rs

This file was deleted.

This file was deleted.

0 comments on commit 033c1e0

Please sign in to comment.