Skip to content

Commit 3826f24

Browse files
committed
????
1 parent b8d1e70 commit 3826f24

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/bin/miri.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
213213
if !many_seeds.keep_going {
214214
// `abort_if_errors` would actually not stop, since `par_for_each` waits for the
215215
// rest of the to finish, so we just exit immediately.
216+
miri::register_retcode_sv(return_code);
216217
std::process::exit(return_code);
217218
}
218219
exit_code.store(return_code, Ordering::Relaxed);
@@ -223,7 +224,9 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
223224
if num_failed > 0 {
224225
eprintln!("{num_failed}/{total} SEEDS FAILED", total = many_seeds.seeds.count());
225226
}
226-
std::process::exit(exit_code.0.into_inner());
227+
let code = exit_code.0.into_inner();
228+
miri::register_retcode_sv(code);
229+
std::process::exit(code);
227230
} else {
228231
let return_code = miri::eval_entry(tcx, entry_def_id, entry_type, &config, None)
229232
.unwrap_or_else(|| {
@@ -232,6 +235,7 @@ impl rustc_driver::Callbacks for MiriCompilerCalls {
232235
tcx.dcx().abort_if_errors();
233236
rustc_driver::EXIT_FAILURE
234237
});
238+
miri::register_retcode_sv(return_code);
235239
std::process::exit(return_code);
236240
}
237241

@@ -329,6 +333,7 @@ impl rustc_driver::Callbacks for MiriBeRustCompilerCalls {
329333

330334
fn show_error(msg: &impl std::fmt::Display) -> ! {
331335
eprintln!("fatal error: {msg}");
336+
miri::register_retcode_sv(1);
332337
std::process::exit(1)
333338
}
334339

@@ -403,6 +408,7 @@ fn run_compiler_and_exit(
403408
// Invoke compiler, and handle return code.
404409
let exit_code =
405410
rustc_driver::catch_with_exit_code(move || rustc_driver::run_compiler(args, callbacks));
411+
miri::register_retcode_sv(exit_code);
406412
std::process::exit(exit_code)
407413
}
408414

@@ -482,7 +488,10 @@ fn main() {
482488
let env_snapshot = env::vars_os().collect::<Vec<_>>();
483489

484490
let args = rustc_driver::catch_fatal_errors(|| rustc_driver::args::raw_args(&early_dcx))
485-
.unwrap_or_else(|_| std::process::exit(rustc_driver::EXIT_FAILURE));
491+
.unwrap_or_else(|_| {
492+
miri::register_retcode_sv(rustc_driver::EXIT_FAILURE);
493+
std::process::exit(rustc_driver::EXIT_FAILURE)
494+
});
486495

487496
// Install the ctrlc handler that sets `rustc_const_eval::CTRL_C_RECEIVED`, even if
488497
// MIRI_BE_RUSTC is set.

src/shims/trace/child.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,8 @@ pub unsafe fn init_sv() -> Result<(), SvInitError> {
202202
// Ptrace works :D
203203
Ok(_) => {
204204
let code = sv_loop(listener, child, event_tx, confirm_tx).unwrap_err();
205-
// If a return code of 0 is not explicitly given, assume something went
206-
// wrong and return 1.
207-
std::process::exit(code.unwrap_or(1))
205+
//eprintln!("Code: {code:?}");
206+
std::process::exit(code.unwrap_or(0))
208207
}
209208
// Ptrace does not work and we failed to catch that.
210209
Err(_) => {

src/shims/trace/parent.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ pub fn sv_loop(
335335
ptrace::syscall(pid, None).unwrap();
336336
}
337337
ExecEvent::Died(code) => {
338+
//eprintln!("Died: {code:?}");
338339
return Err(code);
339340
}
340341
}

0 commit comments

Comments
 (0)