Browse Source

Fix SGX target_env collision

Signed-off-by: Yu Ding <dingelish@gmail.com>
Yu Ding 6 years ago
parent
commit
a9a108548c
3 changed files with 6 additions and 4 deletions
  1. 1 1
      build.rs
  2. 2 1
      src/lib.rs
  3. 3 2
      src/math.rs

+ 1 - 1
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\"");
     }
 

+ 2 - 1
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;
 

+ 3 - 2
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;