Skip to content

Commit c1a5906

Browse files
committed
remove the ability to disable ABI checking
1 parent be5da3a commit c1a5906

17 files changed

+11
-128
lines changed

src/tools/miri/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,6 @@ The remaining flags are for advanced use only, and more likely to change or be r
359359
Some of these are **unsound**, which means they can lead
360360
to Miri failing to detect cases of undefined behavior in a program.
361361

362-
* `-Zmiri-disable-abi-check` disables checking [function ABI]. Using this flag
363-
is **unsound**. This flag is **deprecated**.
364362
* `-Zmiri-disable-alignment-check` disables checking pointer alignment, so you
365363
can focus on other failures, but it means Miri can miss bugs in your program.
366364
Using this flag is **unsound**.

src/tools/miri/src/bin/miri.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,9 @@ fn main() {
413413
);
414414
} else if arg == "-Zmiri-disable-abi-check" {
415415
eprintln!(
416-
"WARNING: the flag `-Zmiri-disable-abi-check` is deprecated and planned to be removed.\n\
417-
If you have a use-case for it, please file an issue."
416+
"WARNING: the flag `-Zmiri-disable-abi-check` no longer has any effect; \
417+
ABI checks cannot be disabled any more"
418418
);
419-
miri_config.check_abi = false;
420419
} else if arg == "-Zmiri-disable-isolation" {
421420
if matches!(isolation_enabled, Some(true)) {
422421
show_error!(

src/tools/miri/src/eval.rs

-3
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ pub struct MiriConfig {
9494
pub unique_is_unique: bool,
9595
/// Controls alignment checking.
9696
pub check_alignment: AlignmentCheck,
97-
/// Controls function [ABI](Abi) checking.
98-
pub check_abi: bool,
9997
/// Action for an op requiring communication with the host.
10098
pub isolated_op: IsolatedOp,
10199
/// Determines if memory leaks should be ignored.
@@ -162,7 +160,6 @@ impl Default for MiriConfig {
162160
borrow_tracker: Some(BorrowTrackerMethod::StackedBorrows),
163161
unique_is_unique: false,
164162
check_alignment: AlignmentCheck::Int,
165-
check_abi: true,
166163
isolated_op: IsolatedOp::Reject(RejectOpWith::Abort),
167164
ignore_leaks: false,
168165
forwarded_env_vars: vec![],

src/tools/miri/src/helpers.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
387387
let this = self.eval_context_mut();
388388
let param_env = ty::ParamEnv::reveal_all(); // in Miri this is always the param_env we use... and this.param_env is private.
389389
let callee_abi = f.ty(*this.tcx, param_env).fn_sig(*this.tcx).abi();
390-
if this.machine.enforce_abi && callee_abi != caller_abi {
390+
if callee_abi != caller_abi {
391391
throw_ub_format!(
392392
"calling a function with ABI {} using caller ABI {}",
393393
callee_abi.name(),
@@ -945,7 +945,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
945945

946946
/// Check that the ABI is what we expect.
947947
fn check_abi<'a>(&self, abi: Abi, exp_abi: Abi) -> InterpResult<'a, ()> {
948-
if self.eval_context_ref().machine.enforce_abi && abi != exp_abi {
948+
if abi != exp_abi {
949949
throw_ub_format!(
950950
"calling a function with ABI {} using caller ABI {}",
951951
exp_abi.name(),

src/tools/miri/src/machine.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,6 @@ pub struct MiriMachine<'mir, 'tcx> {
460460
/// Whether to enforce the validity invariant.
461461
pub(crate) validate: bool,
462462

463-
/// Whether to enforce [ABI](Abi) of function calls.
464-
pub(crate) enforce_abi: bool,
465-
466463
/// The table of file descriptors.
467464
pub(crate) file_handler: shims::unix::FileHandler,
468465
/// The table of directory descriptors.
@@ -641,7 +638,6 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
641638
tls: TlsData::default(),
642639
isolated_op: config.isolated_op,
643640
validate: config.validate,
644-
enforce_abi: config.check_abi,
645641
file_handler: FileHandler::new(config.mute_stdout_stderr),
646642
dir_handler: Default::default(),
647643
layouts,
@@ -784,7 +780,6 @@ impl VisitProvenance for MiriMachine<'_, '_> {
784780
tcx: _,
785781
isolated_op: _,
786782
validate: _,
787-
enforce_abi: _,
788783
clock: _,
789784
layouts: _,
790785
static_roots: _,
@@ -932,8 +927,8 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
932927
}
933928

934929
#[inline(always)]
935-
fn enforce_abi(ecx: &MiriInterpCx<'mir, 'tcx>) -> bool {
936-
ecx.machine.enforce_abi
930+
fn enforce_abi(_ecx: &MiriInterpCx<'mir, 'tcx>) -> bool {
931+
true
937932
}
938933

939934
#[inline(always)]

src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.rs

-29
This file was deleted.

src/tools/miri/tests/fail-dep/concurrency/unwind_top_of_stack.stderr

-21
This file was deleted.

src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ fn main() {
1919
after_call = {
2020
Return()
2121
}
22-
2322
}
2423
}
2524

src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.stack.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ LL | | let _unit: ();
1414
LL | | {
1515
LL | | let non_copy = S(42);
1616
... |
17-
LL | |
17+
LL | | }
1818
LL | | }
1919
| |_____^
2020
help: <TAG> is this argument

src/tools/miri/tests/fail/function_calls/arg_inplace_mutate.tree.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LL | | let _unit: ();
1616
LL | | {
1717
LL | | let non_copy = S(42);
1818
... |
19-
LL | |
19+
LL | | }
2020
LL | | }
2121
| |_____^
2222
help: the protected tag <TAG> was created here, in the initial state Reserved

src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind1.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//@compile-flags: -Zmiri-disable-abi-check
21
#![feature(c_unwind)]
32

43
#[no_mangle]

src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind1.stderr

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
WARNING: the flag `-Zmiri-disable-abi-check` is deprecated and planned to be removed.
2-
If you have a use-case for it, please file an issue.
31
thread 'main' panicked at $DIR/exported_symbol_bad_unwind1.rs:LL:CC:
42
explicit panic
53
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

src/tools/miri/tests/fail/panic/bad_miri_start_unwind.rs

-12
This file was deleted.

src/tools/miri/tests/fail/panic/bad_miri_start_unwind.stderr

-17
This file was deleted.

src/tools/miri/tests/fail/panic/bad_unwind.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#![feature(c_unwind)]
22

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

58
extern "C-unwind" fn unwind() {
69
panic!();

src/tools/miri/tests/pass/function_calls/disable_abi_check.rs

-24
This file was deleted.

src/tools/miri/tests/pass/function_calls/disable_abi_check.stderr

-2
This file was deleted.

0 commit comments

Comments
 (0)