#[cfg(not(any(
    all(target_os = "macos", target_arch = "aarch64"),
    all(target_os = "linux", target_arch = "x86_64")
)))]
fn main() {
    eprintln!("_deadlock_repro only runs on supported VM runtime targets");
}

#[cfg(any(
    all(target_os = "macos", target_arch = "aarch64"),
    all(target_os = "linux", target_arch = "x86_64")
))]
fn main() -> Result<(), Box<dyn std::error::Error>> {
    use std::time::Duration;

    use supermachine::Image;

    eprintln!("[repro] building rust:1-slim with rustc warmup...");
    let _img = Image::builder("rust:1-slim")
        .with_name("_deadlock_repro_v2")
        .with_memory_mib(2048)
        .with_warmup_tag("rustc_v2")
        .with_warmup(|vm| {
            vm.exec_builder()
                .stage_file("/tmp/h.rs", b"fn main(){println!(\"hi\");}".to_vec())
                .argv(["rustc", "-O", "/tmp/h.rs", "-o", "/tmp/h"])
                .timeout(Duration::from_secs(60))
                .output()?;
            Ok(())
        })
        .build()?;
    eprintln!("[repro] OK");
    Ok(())
}
