Skip to content

Commit add6f14

Browse files
authored
Rollup merge of #104241 - bjorn3:smaller_unwind_build_script, r=Mark-Simulacrum
Move most of unwind's build script to lib.rs Only the android libunwind detection remains in the build script * Reduces dependence on build scripts for building the standard library * Reduces dependence on exact target names in favor of using semantic cfg(target_*) usage. * Keeps almost all code related to linking of the unwinder in one file
2 parents 47f9d89 + 53852ee commit add6f14

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

library/unwind/build.rs

-24
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,5 @@ fn main() {
2121
if has_unwind {
2222
println!("cargo:rustc-cfg=feature=\"system-llvm-libunwind\"");
2323
}
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");
31-
} else {
32-
println!("cargo:rustc-link-lib=c++abi");
33-
}
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
4824
}
4925
}

library/unwind/src/lib.rs

+24
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,27 @@ extern "C" {}
103103
#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
104104
#[link(name = "unwind", kind = "static", modifiers = "-bundle")]
105105
extern "C" {}
106+
107+
#[cfg(any(target_os = "freebsd", target_os = "netbsd"))]
108+
#[link(name = "gcc_s")]
109+
extern "C" {}
110+
111+
#[cfg(all(target_os = "openbsd", target_arch = "sparc64"))]
112+
#[link(name = "gcc")]
113+
extern "C" {}
114+
115+
#[cfg(all(target_os = "openbsd", not(target_arch = "sparc64")))]
116+
#[link(name = "c++abi")]
117+
extern "C" {}
118+
119+
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
120+
#[link(name = "gcc_s")]
121+
extern "C" {}
122+
123+
#[cfg(target_os = "dragonfly")]
124+
#[link(name = "gcc_pic")]
125+
extern "C" {}
126+
127+
#[cfg(target_os = "haiku")]
128+
#[link(name = "gcc_s")]
129+
extern "C" {}

0 commit comments

Comments
 (0)