From a9a108548c93774640b5819c3bbb1fce5d95dfd2 Mon Sep 17 00:00:00 2001 From: Yu Ding Date: Thu, 3 Jan 2019 12:53:08 -0800 Subject: [PATCH] Fix SGX target_env collision Signed-off-by: Yu Ding --- build.rs | 2 +- src/lib.rs | 3 ++- src/math.rs | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build.rs b/build.rs index 752bba1..78a4ce2 100644 --- a/build.rs +++ b/build.rs @@ -22,7 +22,7 @@ fn main() { // Forcibly enable memory intrinsics on wasm32 & SGX as we don't have a libc to // provide them. - if target.contains("wasm32") || target.contains("sgx") { + if target.contains("wasm32") || (target.contains("sgx") && target.contains("fortanix")) { println!("cargo:rustc-cfg=feature=\"mem\""); } diff --git a/src/lib.rs b/src/lib.rs index 9bb38f3..0acb006 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,6 +16,7 @@ #![feature(abi_unadjusted)] #![feature(linkage)] #![feature(lang_items)] +#![feature(cfg_target_vendor)] #![allow(unused_features)] #![no_builtins] #![cfg_attr(feature = "compiler-builtins", feature(staged_api))] @@ -49,7 +50,7 @@ pub mod float; #[cfg(any(all(target_arch = "wasm32", target_os = "unknown"), all(target_arch = "arm", target_os = "none"), - target_env = "sgx"))] + all(target_vendor = "fortanix", target_env = "sgx")))] pub mod math; pub mod mem; diff --git a/src/math.rs b/src/math.rs index e2b15c6..18def0e 100644 --- a/src/math.rs +++ b/src/math.rs @@ -15,7 +15,8 @@ macro_rules! no_mangle { } // only for the wasm32-unknown-unknown target -#[cfg(any(all(target_arch = "wasm32", target_os = "unknown"), target_env = "sgx"))] +#[cfg(any(all(target_arch = "wasm32", target_os = "unknown"), + all(target_vendor = "fortanix", target_env = "sgx")))] no_mangle! { fn acos(x: f64) -> f64; fn asin(x: f64) -> f64; @@ -66,7 +67,7 @@ no_mangle! { fn tanhf(n: f32) -> f32; } -#[cfg(target_env = "sgx")] +#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] no_mangle! { fn ceil(x: f64) -> f64; fn ceilf(x: f32) -> f32;