| // Copyright 2026 The Fuchsia Authors | |
| // | |
| // Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 | |
| // <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT | |
| // license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option. | |
| // This file may not be copied, modified, or distributed except according to | |
| // those terms. | |
| //! Host `rustc` differential execution authority compiling and running each | |
| //! defined-behavior test case at BOTH `-C opt-level=0` AND `-C opt-level=2` and | |
| //! asserting `O0 == O2` parity across `TerminalOutcome`, `ObservableSpine`, and | |
| //! `CallerFrameLaw`. | |
| use std::{ | |
| env, | |
| ffi::{OsStr, OsString}, | |
| fs, | |
| io::Write, | |
| path::{Path, PathBuf}, | |
| process::ExitStatus, | |
| time::{Duration, Instant}, | |
| }; | |
| use anneal_testkit::{Invocation, ProcessOutcome, ProcessSupervisor, Termination}; | |
| use serde::{Deserialize, Serialize}; | |
| use crate::{ | |
| outcome::{AuthorityRunResult, compare_spines}, | |
| spec::{ | |
| TraceTestCase, parse_pre_abort_stdout_with_expected_args, | |
| parse_trace_json_stdout_with_expected_args, render_standalone_rust_harness, | |
| }, | |
| trace_observer::PRE_ABORT_JSON_PREFIX, | |
| }; | |
| mod discovery; | |
| #[path = "rustc_runner/exec.rs"] | |
| mod exec; | |
| mod invocation; | |
| mod parse; | |
| #[path = "rustc_runner/resolve.rs"] | |
| mod resolve; | |
| pub use discovery::*; | |
| pub use invocation::*; | |
| pub use parse::*; | |
| const RUSTC_COMPILE_TIMEOUT_SECS: u64 = 90; | |
| const RUSTC_RUN_TIMEOUT_SECS: u64 = 30; | |
| /// Combined result of running a trace case under `rustc -C opt-level=0` and | |
| /// `rustc -C opt-level=2`. | |
| #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] | |
| pub struct RustcDualResult { | |
| pub o0: AuthorityRunResult, | |
| pub o2: AuthorityRunResult, | |
| pub parity_ok: bool, | |
| pub skipped_for_ub: bool, | |
| pub mismatch_detail: Option<String>, | |
| } | |
| impl RustcDualResult { | |
| /// Construct a clean placeholder when host `rustc` execution is skipped | |
| /// because Miri proved UB or the case is an explicit `expected_ub` probe. | |
| pub fn skipped_for_ub(reason: &str) -> Self { | |
| Self { | |
| o0: AuthorityRunResult::skipped_for_ub("rustc-O0", reason), | |
| o2: AuthorityRunResult::skipped_for_ub("rustc-O2", reason), | |
| parity_ok: false, | |
| skipped_for_ub: true, | |
| mismatch_detail: None, | |
| } | |
| } | |
| } | |
| /// Prepared host `rustc` session bound to a consistent compiler sysroot and | |
| /// validated 64-bit little-endian native host target triple. | |
| #[derive(Clone, Debug)] | |
| pub struct RustcRunner { | |
| pub rustc_bin: PathBuf, | |
| pub sysroot: Option<PathBuf>, | |
| pub host_target: String, | |
| } |