]> git.proxmox.com Git - rustc.git/blob - library/unwind/build.rs
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / library / unwind / build.rs
1 use std::env;
2
3 fn main() {
4 println!("cargo:rerun-if-changed=build.rs");
5 let target = env::var("TARGET").expect("TARGET was not set");
6
7 if target.contains("android") {
8 let build = cc::Build::new();
9
10 // Since ndk r23 beta 3 `libgcc` was replaced with `libunwind` thus
11 // check if we have `libunwind` available and if so use it. Otherwise
12 // fall back to `libgcc` to support older ndk versions.
13 let has_unwind = build.is_flag_supported("-lunwind").expect("Unable to invoke compiler");
14
15 if has_unwind {
16 println!("cargo:rustc-link-lib=unwind");
17 } else {
18 println!("cargo:rustc-link-lib=gcc");
19 }
20 } else if target.contains("freebsd") {
21 println!("cargo:rustc-link-lib=gcc_s");
22 } else if target.contains("netbsd") {
23 println!("cargo:rustc-link-lib=gcc_s");
24 } else if target.contains("openbsd") {
25 if target.contains("sparc64") {
26 println!("cargo:rustc-link-lib=gcc");
27 } else {
28 println!("cargo:rustc-link-lib=c++abi");
29 }
30 } else if target.contains("solaris") {
31 println!("cargo:rustc-link-lib=gcc_s");
32 } else if target.contains("illumos") {
33 println!("cargo:rustc-link-lib=gcc_s");
34 } else if target.contains("dragonfly") {
35 println!("cargo:rustc-link-lib=gcc_pic");
36 } else if target.contains("pc-windows-gnu") {
37 // This is handled in the target spec with late_link_args_[static|dynamic]
38 } else if target.contains("uwp-windows-gnu") {
39 println!("cargo:rustc-link-lib=unwind");
40 } else if target.contains("fuchsia") {
41 println!("cargo:rustc-link-lib=unwind");
42 } else if target.contains("haiku") {
43 println!("cargo:rustc-link-lib=gcc_s");
44 } else if target.contains("redox") {
45 // redox is handled in lib.rs
46 }
47 }