From ed1297c92a77997178ad7aadb9d0cc087d15e0af Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 17 May 2020 21:08:23 +0300 Subject: [PATCH] rustc_target: Avoid an inappropriate use of `post_link_objects` --- src/librustc_target/spec/x86_64_fortanix_unknown_sgx.rs | 4 +--- src/libunwind/lib.rs | 4 ++++ 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 d26efc0985952..475a33af29c79 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 { const PRE_LINK_ARGS: &[&str] = &[ @@ -68,8 +68,6 @@ pub fn target() -> Result { 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 18d41be77398b..cc025da1af555 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" {}