about summary refs log tree commit diff
path: root/tests/run-make-cargo/panic-immediate-abort-works/rmake.rs
blob: 3eeef38c962dc15ce4441130ef1692d56219340c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// This test ensures we are able to compile and link a simple binary with panic=immediate-abort.
// The test panic-immediate-abort-codegen checks that panic strategy produces the desired codegen,
// but is based on compiling a library crate (which is the norm for codegen tests because it is
// cleaner and more portable). So this test ensures that we didn't mix up a cfg or a compiler
// implementation detail in a way that makes panic=immediate-abort encounter errors at link time.

// Ideally this test would be run for most targets, but unfortunately:
// This test is currently written using `fn main() {}` which requires std.
// And since the default linker is only a linker for the host, we can't handle cross-compilation.
// Both of these shortcomings could be addressed at the cost of making the test more complicated.
//@ needs-target-std
//@ ignore-cross-compile

#![deny(warnings)]

use run_make_support::{cargo, path, target};

fn main() {
    let target_dir = path("target");

    cargo()
        .current_dir("hello")
        .args(&[
            "build",
            "--release",
            "--manifest-path",
            "Cargo.toml",
            "-Zbuild-std",
            "--target",
            &target(),
        ])
        .env("RUSTFLAGS", "-Zunstable-options -Cpanic=immediate-abort")
        .env("CARGO_TARGET_DIR", &target_dir)
        .env("RUSTC_BOOTSTRAP", "1")
        // Visual Studio 2022 requires that the LIB env var be set so it can
        // find the Windows SDK.
        .env("LIB", std::env::var("LIB").unwrap_or_default())
        .run();
}