From 2701bdbbac5fa0b59fb4042d79bc5c4634b2b22b Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 22 Oct 2018 19:39:32 -0700 Subject: [PATCH] Prevent excess precision errors on 32-bit builds The compile flag -ffloat-store requires floating point values to be stored in memory rather than in registers to prevent errors when two numbers are compared that were stored in different locations. (cherry picked from commit 40c70dd00853c2c13c57f88f186e7a14f74c09f6) --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 098dcd1e36..718d76a649 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -274,6 +274,10 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) set( TO_LINKER -XLinker ) else() set( TO_LINKER -Wl ) + # Set 32-bit flag for GCC to prevent excess precision + if( CMAKE_SIZEOF_VOID_P EQUAL 4 ) + set( CMAKE_CXX_FLAGS "-ffloat-store ${CMAKE_CXX_FLAGS}" ) + endif() endif() # Establish -Wall early, so specialized relaxations of this may come