use SSE registers for FP operations on i386 for moder gcc platform arches

* only use if related are given, by example 32bit using gcc compilers/stdlibs
  becouse of the long time bugs around those errors by desing,
  its not about to crash the engine.. its about to permits to hacked clients
  (either players or the client program per se) making predictable results,
  so predictable results permits to catch securit issues!
* floating point problems are only on modern gcc and modern platform arches,
  raising problems like bad calculations positions.. a long time bug
  reported at https://git.minetest.land/Mineclonia/Mineclonia/issues/201
  and addressed at https://github.com/minetest/minetest/issues/11742#issuecomment-994444462
  with enought explanations but not accepted byt stupid developers..
  now years later.. the problems were solved and reconiced as big bug!
  A workaround were proposed at https://github.com/minetest/minetest/pull/12389/files
  but never accepted (included in this repository), cos was superset
  by 8ff3fadba0
* related https://codeberg.org/minenux/minetest-engine-multicraft2/issues/57
This commit is contained in:
mckaygerhard 2023-09-13 00:54:04 -04:00
parent 696ec9a022
commit e713d3567c

View File

@ -830,6 +830,21 @@ else()
set(OTHER_FLAGS "${OTHER_FLAGS} -mthreads -fexceptions")
endif()
# only related to moder x86 32bit platforms using gcc compilers
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.7)
# Enable SSE for floating point math on 32-bit x86 by default
# reasoning see minetest issue #11810 and https://gcc.gnu.org/wiki/FloatingPointMath
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
check_c_source_compiles("#ifndef __i686__\n#error\n#endif\nint main(){}" IS_I686)
if(IS_I686)
message(STATUS "Detected Intel x86: using SSE instead of x87 FPU")
set(OTHER_FLAGS "${OTHER_FLAGS} -mfpmath=sse -msse")
endif()
endif()
endif()
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} ${OTHER_FLAGS} -Wall -pipe -funroll-loops")
if(CMAKE_SYSTEM_NAME MATCHES "(Darwin|BSD|DragonFly)")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS} -Os")