From e2cc33f9d3d401fe4b7c91bc848f64573a1e831c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 17 Jun 2016 18:18:30 +0200 Subject: [PATCH] Math: don't use std::fma() on Emscripten. With -O2 the test works, but with -O1 the compiler complains about missing instruction. I guess -O2 just optimizes it away in this particular case, so the safe option is to not use it at all. --- src/Magnum/Math/Functions.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Magnum/Math/Functions.h b/src/Magnum/Math/Functions.h index 3c3ff7b57..333313892 100644 --- a/src/Magnum/Math/Functions.h +++ b/src/Magnum/Math/Functions.h @@ -498,7 +498,10 @@ template inline T fma(const T& a, const T& b, const T& c); #else template inline typename std::enable_if::value, T>::type fma(T a, T b, T c) { /** @todo Remove when newlib has this fixed */ - #if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) + /* On Emscripten it works with -O2 but not with -O1 (function not defined). + I guess that's only because -O2 optimizes it out, so disabling it there + also */ + #if !defined(CORRADE_TARGET_NACL_NEWLIB) && !defined(CORRADE_TARGET_ANDROID) && !defined(CORRADE_TARGET_EMSCRIPTEN) return std::fma(a, b, c); #else return a*b + c;