4 println!("cargo:rerun-if-changed=build.rs");
5 println!("cargo:rerun-if-env-changed=CARGO_CFG_MIRI");
7 if env::var_os("CARGO_CFG_MIRI").is_some() {
8 // Miri doesn't need the linker flags or a libunwind build.
12 let target = env::var("TARGET").expect("TARGET was not set");
13 if target.contains("android") {
14 let build = cc::Build::new();
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");
22 println!("cargo:rustc-cfg=feature=\"system-llvm-libunwind\"");
24 } else if target.contains("freebsd") {
25 println!("cargo:rustc-link-lib=gcc_s");
26 } else if target.contains("netbsd") {
27 println!("cargo:rustc-link-lib=gcc_s");
28 } else if target.contains("openbsd") {
29 if target.contains("sparc64") {
30 println!("cargo:rustc-link-lib=gcc");
32 println!("cargo:rustc-link-lib=c++abi");
34 } else if target.contains("solaris") {
35 println!("cargo:rustc-link-lib=gcc_s");
36 } else if target.contains("illumos") {
37 println!("cargo:rustc-link-lib=gcc_s");
38 } else if target.contains("dragonfly") {
39 println!("cargo:rustc-link-lib=gcc_pic");
40 } else if target.ends_with("pc-windows-gnu") {
41 // This is handled in the target spec with late_link_args_[static|dynamic]
42 } else if target.contains("uwp-windows-gnu") {
43 println!("cargo:rustc-link-lib=unwind");
44 } else if target.contains("haiku") {
45 println!("cargo:rustc-link-lib=gcc_s");
46 } else if target.contains("redox") {
47 // redox is handled in lib.rs