Эх сурвалжийг харах

armhf: don't compare our impls against gcc_s

Jorge Aparicio 8 жил өмнө
parent
commit
337bd7e209
3 өөрчлөгдсөн 23 нэмэгдсэн , 8 устгасан
  1. 1 0
      Cargo.toml
  2. 7 0
      build.rs
  3. 15 8
      src/float/add.rs

+ 1 - 0
Cargo.toml

@@ -1,5 +1,6 @@
 [package]
 authors = ["Jorge Aparicio <japaricious@gmail.com>"]
+build = "build.rs"
 name = "rustc_builtins"
 version = "0.1.0"
 

+ 7 - 0
build.rs

@@ -0,0 +1,7 @@
+use std::env;
+
+fn main() {
+    if env::var("TARGET").unwrap().ends_with("hf") {
+        println!("cargo:rustc-cfg=gnueabihf")
+    }
+}

+ 15 - 8
src/float/add.rs

@@ -216,10 +216,15 @@ mod tests {
             let (a, b) = (f32::from_repr(a.0), f32::from_repr(b.0));
             let x = super::__addsf3(a, b);
 
-            if let Some(addsf3) = gcc_s::addsf3() {
-               x.eq_repr(unsafe { addsf3(a, b) })
-            } else {
-                x.eq_repr(a + b)
+            match gcc_s::addsf3() {
+                // NOTE(cfg) for some reason, on hard float targets, our implementation doesn't
+                // match the output of its gcc_s counterpart. Until we investigate further, we'll
+                // just avoid testing against gcc_s on those targets. Do note that our
+                // implementation matches the output of the FPU instruction on *hard* float targets
+                // and matches its gcc_s counterpart on *soft* float targets.
+                #[cfg(not(gnueabihf))]
+                Some(addsf3) => x.eq_repr(unsafe { addsf3(a, b) }),
+                _ => x.eq_repr(a + b),
             }
         }
 
@@ -227,10 +232,12 @@ mod tests {
             let (a, b) = (f64::from_repr(a.0), f64::from_repr(b.0));
             let x = super::__adddf3(a, b);
 
-            if let Some(adddf3) = gcc_s::adddf3() {
-                x.eq_repr(unsafe { adddf3(a, b) })
-            } else {
-                x.eq_repr(a + b)
+            match gcc_s::adddf3() {
+                // NOTE(cfg) See NOTE above
+                #[cfg(not(gnueabihf))]
+                Some(adddf3) => x.eq_repr(unsafe { adddf3(a, b) }),
+                _ => x.eq_repr(a + b),
+
             }
         }
     }