aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-12-20 14:07:54 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-12-20 14:07:54 +0000
commit151f6d05f04cc97cc9031c2bdd281303f9f0173a (patch)
tree8da00906d41f63e5eab747f6d6d2ba791b51285d /cmake
parentf33d6b0d3f2fd5418c9380e99fa27e141e5226b4 (diff)
downloadrspamd-151f6d05f04cc97cc9031c2bdd281303f9f0173a.tar.gz
rspamd-151f6d05f04cc97cc9031c2bdd281303f9f0173a.zip
[Minor] Fix fast math usage
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Toolset.cmake16
1 files changed, 11 insertions, 5 deletions
diff --git a/cmake/Toolset.cmake b/cmake/Toolset.cmake
index f96fc39f9..dc4b17bf5 100644
--- a/cmake/Toolset.cmake
+++ b/cmake/Toolset.cmake
@@ -1,15 +1,21 @@
option (ENABLE_FAST_MATH "Build rspamd with fast math compiler flag [default: ON]" ON)
-SET (COMPILER_FAST_MATH "")
-if (ENABLE_FAST_MATH MATCHES "ON")
- SET (COMPILER_FAST_MATH "-ffast-math")
-endif ()
-
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
SET (COMPILER_GCC 1)
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang|AppleClang")
SET (COMPILER_CLANG 1)
endif()
+
+SET (COMPILER_FAST_MATH "")
+if (ENABLE_FAST_MATH MATCHES "ON")
+ # We need to keep nans and infinities, so cannot keep all fast math there
+ IF (COMPILER_CLANG)
+ SET (COMPILER_FAST_MATH "-fassociative-math -freciprocal-math -fno-signed-zeros -ffp-contract=fast")
+ ELSE()
+ SET (COMPILER_FAST_MATH "-funsafe-math-optimizations -fno-math-errno")
+ ENDIF ()
+endif ()
+
if (CMAKE_GENERATOR STREQUAL "Ninja")
# Turn on colored output. https://github.com/ninja-build/ninja/wiki/FAQ
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")