4 println!("cargo:rerun-if-changed=build.rs");
5 let target = env::var("TARGET").expect("TARGET was not set");
7 if target.contains("android") {
8 let build = cc::Build::new();
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");
16 println!("cargo:rustc-cfg=feature=\"system-llvm-libunwind\"");
18 } else if target.contains("freebsd") {
19 println!("cargo:rustc-link-lib=gcc_s");
20 } else if target.contains("netbsd") {
21 println!("cargo:rustc-link-lib=gcc_s");
22 } else if target.contains("openbsd") {
23 if target.contains("sparc64") {
24 println!("cargo:rustc-link-lib=gcc");
26 println!("cargo:rustc-link-lib=c++abi");
28 } else if target.contains("solaris") {
29 println!("cargo:rustc-link-lib=gcc_s");
30 } else if target.contains("illumos") {
31 println!("cargo:rustc-link-lib=gcc_s");
32 } else if target.contains("dragonfly") {
33 println!("cargo:rustc-link-lib=gcc_pic");
34 } else if target.ends_with("pc-windows-gnu") {
35 // This is handled in the target spec with late_link_args_[static|dynamic]
36 } else if target.contains("uwp-windows-gnu") {
37 println!("cargo:rustc-link-lib=unwind");
38 } else if target.contains("haiku") {
39 println!("cargo:rustc-link-lib=gcc_s");
40 } else if target.contains("redox") {
41 // redox is handled in lib.rs