diff --git a/src/machine.rs b/src/machine.rs index 1fdc398dd9f..6cce1a5db25 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -291,6 +291,9 @@ pub struct Evaluator<'mir, 'tcx> { /// Failure rate of compare_exchange_weak, between 0.0 and 1.0 pub(crate) cmpxchg_weak_failure_rate: f64, + + /// Corresponds to -Zmiri-drop-stdout-stderr and doesn't write the output but acts as if it succeeded. + pub(crate) drop_stdout_stderr: bool, } impl<'mir, 'tcx> Evaluator<'mir, 'tcx> { @@ -344,6 +347,7 @@ impl<'mir, 'tcx> Evaluator<'mir, 'tcx> { tracked_alloc_ids: config.tracked_alloc_ids.clone(), check_alignment: config.check_alignment, cmpxchg_weak_failure_rate: config.cmpxchg_weak_failure_rate, + drop_stdout_stderr: config.drop_stdout_stderr, } } diff --git a/src/shims/windows/dlsym.rs b/src/shims/windows/dlsym.rs index ac9e085b5d7..05230531d91 100644 --- a/src/shims/windows/dlsym.rs +++ b/src/shims/windows/dlsym.rs @@ -75,7 +75,9 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx use std::io::{self, Write}; let buf_cont = this.read_bytes_ptr(buf, Size::from_bytes(u64::from(n)))?; - let res = if handle == -11 { + let res = if this.machine.drop_stdout_stderr { + Ok(buf_cont.len()) + } else if handle == -11 { io::stdout().write(buf_cont) } else { io::stderr().write(buf_cont)