From 337bd7e209866e816515b34bbb5f849f2fa08e13 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Wed, 21 Sep 2016 21:14:38 -0500 Subject: [PATCH] armhf: don't compare our impls against gcc_s --- Cargo.toml | 1 + build.rs | 7 +++++++ src/float/add.rs | 23 +++++++++++++++-------- 3 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 build.rs diff --git a/Cargo.toml b/Cargo.toml index 229cec7..d378461 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [package] authors = ["Jorge Aparicio "] +build = "build.rs" name = "rustc_builtins" version = "0.1.0" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..1ff0c06 --- /dev/null +++ b/build.rs @@ -0,0 +1,7 @@ +use std::env; + +fn main() { + if env::var("TARGET").unwrap().ends_with("hf") { + println!("cargo:rustc-cfg=gnueabihf") + } +} diff --git a/src/float/add.rs b/src/float/add.rs index 13c7aba..0943e2e 100644 --- a/src/float/add.rs +++ b/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), + } } }