about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2022-11-10 12:17:31 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2022-11-14 14:24:12 +0000
commit53852ee4eb1fed3a616cd2f99ac77fc3d5bd296b (patch)
tree36e8c73530a94305d37f8b5b3747cd401cbe8cb2
parent96ddd32c4bfb1d78f0cd03eb068b1710a8cebeef (diff)
downloadrust-53852ee4eb1fed3a616cd2f99ac77fc3d5bd296b.tar.gz
rust-53852ee4eb1fed3a616cd2f99ac77fc3d5bd296b.zip
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
-rw-r--r--library/unwind/build.rs24
-rw-r--r--library/unwind/src/lib.rs24
2 files changed, 24 insertions, 24 deletions
diff --git a/library/unwind/build.rs b/library/unwind/build.rs
index 31af390253b..5c3c02fb6ad 100644
--- a/library/unwind/build.rs
+++ b/library/unwind/build.rs
@@ -21,29 +21,5 @@ fn main() {
         if has_unwind {
             println!("cargo:rustc-cfg=feature=\"system-llvm-libunwind\"");
         }
-    } 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
     }
 }
diff --git a/library/unwind/src/lib.rs b/library/unwind/src/lib.rs
index 2efd2d5dd4a..3753071d5f0 100644
--- a/library/unwind/src/lib.rs
+++ b/library/unwind/src/lib.rs
@@ -103,3 +103,27 @@ extern "C" {}
 #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
 #[link(name = "unwind", kind = "static", modifiers = "-bundle")]
 extern "C" {}
+
+#[cfg(any(target_os = "freebsd", target_os = "netbsd"))]
+#[link(name = "gcc_s")]
+extern "C" {}
+
+#[cfg(all(target_os = "openbsd", target_arch = "sparc64"))]
+#[link(name = "gcc")]
+extern "C" {}
+
+#[cfg(all(target_os = "openbsd", not(target_arch = "sparc64")))]
+#[link(name = "c++abi")]
+extern "C" {}
+
+#[cfg(any(target_os = "solaris", target_os = "illumos"))]
+#[link(name = "gcc_s")]
+extern "C" {}
+
+#[cfg(target_os = "dragonfly")]
+#[link(name = "gcc_pic")]
+extern "C" {}
+
+#[cfg(target_os = "haiku")]
+#[link(name = "gcc_s")]
+extern "C" {}