]> git.lizzy.rs Git - rust.git/blob - library/unwind/build.rs
Rollup merge of #106292 - Nilstrieb:box-uninit-test, r=RalfJung
[rust.git] / library / unwind / build.rs
1 use std::env;
2
3 fn main() {
4     println!("cargo:rerun-if-changed=build.rs");
5     println!("cargo:rerun-if-env-changed=CARGO_CFG_MIRI");
6
7     if env::var_os("CARGO_CFG_MIRI").is_some() {
8         // Miri doesn't need the linker flags or a libunwind build.
9         return;
10     }
11
12     let target = env::var("TARGET").expect("TARGET was not set");
13     if target.contains("android") {
14         let build = cc::Build::new();
15
16         // Since ndk r23 beta 3 `libgcc` was replaced with `libunwind` thus
17         // check if we have `libunwind` available and if so use it. Otherwise
18         // fall back to `libgcc` to support older ndk versions.
19         let has_unwind = build.is_flag_supported("-lunwind").expect("Unable to invoke compiler");
20
21         if has_unwind {
22             println!("cargo:rustc-cfg=feature=\"system-llvm-libunwind\"");
23         }
24     }
25 }