about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-05-22 08:54:51 +0200
committerGitHub <noreply@github.com>2020-05-22 08:54:51 +0200
commit0eba15220d339f91f9cb01fdfa68d7d7caf85d13 (patch)
tree4e41547e5b4598e7a9587938147069a076be9e94
parent715f1e84787b0e7a1d8b751eeece53f1afb848b4 (diff)
parented1297c92a77997178ad7aadb9d0cc087d15e0af (diff)
downloadrust-0eba15220d339f91f9cb01fdfa68d7d7caf85d13.tar.gz
rust-0eba15220d339f91f9cb01fdfa68d7d7caf85d13.zip
Rollup merge of #72304 - petrochenkov:sgxunwind, r=nikomatsakis,jethrogb,dingelish
rustc_target: Avoid an inappropriate use of `post_link_objects`

It isn't supposed to be used for linking libraries.
Also linking libunwind unconditionally (and not together with the `src/libunwind` crate) is suspicious.

@jethrogb @VardhanThigle
Could you verify that it works as expected?
-rw-r--r--src/librustc_target/spec/x86_64_fortanix_unknown_sgx.rs4
-rw-r--r--src/libunwind/lib.rs4
2 files changed, 5 insertions, 3 deletions
diff --git a/src/librustc_target/spec/x86_64_fortanix_unknown_sgx.rs b/src/librustc_target/spec/x86_64_fortanix_unknown_sgx.rs
index d26efc09859..475a33af29c 100644
--- a/src/librustc_target/spec/x86_64_fortanix_unknown_sgx.rs
+++ b/src/librustc_target/spec/x86_64_fortanix_unknown_sgx.rs
@@ -1,6 +1,6 @@
 use std::iter;
 
-use super::{crt_objects, LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions};
+use super::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions};
 
 pub fn target() -> Result<Target, String> {
     const PRE_LINK_ARGS: &[&str] = &[
@@ -68,8 +68,6 @@ pub fn target() -> Result<Target, String> {
             PRE_LINK_ARGS.iter().cloned().map(String::from).collect(),
         ))
         .collect(),
-        // FIXME: libunwind is certainly not a CRT object, use some other option instead.
-        post_link_objects: crt_objects::all("libunwind.a"),
         override_export_symbols: Some(EXPORT_SYMBOLS.iter().cloned().map(String::from).collect()),
         relax_elf_relocations: true,
         ..Default::default()
diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs
index 18d41be7739..cc025da1af5 100644
--- a/src/libunwind/lib.rs
+++ b/src/libunwind/lib.rs
@@ -27,3 +27,7 @@ extern "C" {}
 #[link(name = "gcc_eh", kind = "static-nobundle", cfg(target_feature = "crt-static"))]
 #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
 extern "C" {}
+
+#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
+#[link(name = "unwind", kind = "static-nobundle")]
+extern "C" {}