summaryrefslogtreecommitdiffstats
path: root/library/unwind/build.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /library/unwind/build.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/unwind/build.rs')
-rw-r--r--library/unwind/build.rs48
1 files changed, 48 insertions, 0 deletions
diff --git a/library/unwind/build.rs b/library/unwind/build.rs
new file mode 100644
index 000000000..f88e6a924
--- /dev/null
+++ b/library/unwind/build.rs
@@ -0,0 +1,48 @@
+use std::env;
+
+fn main() {
+ println!("cargo:rerun-if-changed=build.rs");
+ let target = env::var("TARGET").expect("TARGET was not set");
+
+ if target.contains("android") {
+ let build = cc::Build::new();
+
+ // Since ndk r23 beta 3 `libgcc` was replaced with `libunwind` thus
+ // check if we have `libunwind` available and if so use it. Otherwise
+ // fall back to `libgcc` to support older ndk versions.
+ let has_unwind = build.is_flag_supported("-lunwind").expect("Unable to invoke compiler");
+
+ if has_unwind {
+ println!("cargo:rustc-link-lib=unwind");
+ } else {
+ println!("cargo:rustc-link-lib=gcc");
+ }
+
+ // Android's unwinding library depends on dl_iterate_phdr in `libdl`.
+ println!("cargo:rustc-link-lib=dl");
+ } else if target.contains("freebsd") {
+ println!("cargo:rustc-link-lib=gcc_s");
+ } else if target.contains("netbsd") {
+ println!("cargo:rustc-link-lib=gcc_s");
+ } else if target.contains("openbsd") {
+ if target.contains("sparc64") {
+ println!("cargo:rustc-link-lib=gcc");
+ } else {
+ println!("cargo:rustc-link-lib=c++abi");
+ }
+ } else if target.contains("solaris") {
+ println!("cargo:rustc-link-lib=gcc_s");
+ } else if target.contains("illumos") {
+ println!("cargo:rustc-link-lib=gcc_s");
+ } else if target.contains("dragonfly") {
+ println!("cargo:rustc-link-lib=gcc_pic");
+ } else if target.ends_with("pc-windows-gnu") {
+ // This is handled in the target spec with late_link_args_[static|dynamic]
+ } else if target.contains("uwp-windows-gnu") {
+ println!("cargo:rustc-link-lib=unwind");
+ } else if target.contains("haiku") {
+ println!("cargo:rustc-link-lib=gcc_s");
+ } else if target.contains("redox") {
+ // redox is handled in lib.rs
+ }
+}