]>
Commit | Line | Data |
---|---|---|
a7813a04 XL |
1 | use std::env; |
2 | ||
3 | fn main() { | |
8bb4bdeb | 4 | println!("cargo:rerun-if-changed=build.rs"); |
9e0c209e | 5 | let target = env::var("TARGET").expect("TARGET was not set"); |
a7813a04 | 6 | |
94222f64 XL |
7 | if target.contains("android") { |
8 | let build = cc::Build::new(); | |
17df50a5 | 9 | |
94222f64 XL |
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"); | |
17df50a5 | 14 | |
94222f64 XL |
15 | if has_unwind { |
16 | println!("cargo:rustc-link-lib=unwind"); | |
17 | } else { | |
18 | println!("cargo:rustc-link-lib=gcc"); | |
a7813a04 | 19 | } |
a2a8927a XL |
20 | |
21 | // Android's unwinding library depends on dl_iterate_phdr in `libdl`. | |
22 | println!("cargo:rustc-link-lib=dl"); | |
a7813a04 XL |
23 | } else if target.contains("freebsd") { |
24 | println!("cargo:rustc-link-lib=gcc_s"); | |
a7813a04 XL |
25 | } else if target.contains("netbsd") { |
26 | println!("cargo:rustc-link-lib=gcc_s"); | |
27 | } else if target.contains("openbsd") { | |
e1599b0c XL |
28 | if target.contains("sparc64") { |
29 | println!("cargo:rustc-link-lib=gcc"); | |
30 | } else { | |
31 | println!("cargo:rustc-link-lib=c++abi"); | |
32 | } | |
8bb4bdeb XL |
33 | } else if target.contains("solaris") { |
34 | println!("cargo:rustc-link-lib=gcc_s"); | |
ba9703b0 XL |
35 | } else if target.contains("illumos") { |
36 | println!("cargo:rustc-link-lib=gcc_s"); | |
a7813a04 XL |
37 | } else if target.contains("dragonfly") { |
38 | println!("cargo:rustc-link-lib=gcc_pic"); | |
416331ca | 39 | } else if target.contains("pc-windows-gnu") { |
ba9703b0 | 40 | // This is handled in the target spec with late_link_args_[static|dynamic] |
416331ca XL |
41 | } else if target.contains("uwp-windows-gnu") { |
42 | println!("cargo:rustc-link-lib=unwind"); | |
c30ab7b3 SL |
43 | } else if target.contains("fuchsia") { |
44 | println!("cargo:rustc-link-lib=unwind"); | |
7cac9316 XL |
45 | } else if target.contains("haiku") { |
46 | println!("cargo:rustc-link-lib=gcc_s"); | |
3b2f2976 | 47 | } else if target.contains("redox") { |
416331ca | 48 | // redox is handled in lib.rs |
a7813a04 XL |
49 | } |
50 | } |