forked from Mirrorlandia_minetest/minetest
Swap out -ffast-math for a safe subset of optimization flags (#9682)
It caused more trouble than its worth. fixes #3943, fixes #5330
This commit is contained in:
parent
e8ac5a31cf
commit
5cbe8437a8
@ -713,6 +713,11 @@ else()
|
|||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWIN32_LEAN_AND_MEAN")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWIN32_LEAN_AND_MEAN")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Use a safe subset of flags to speed up math calculations:
|
||||||
|
# - we don't need errno or math exceptions
|
||||||
|
# - we don't deal with Inf/NaN or signed zero
|
||||||
|
set(MATH_FLAGS "-fno-math-errno -fno-trapping-math -ffinite-math-only -fno-signed-zeros")
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} ${OTHER_FLAGS} -Wall -pipe -funroll-loops")
|
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)")
|
if(CMAKE_SYSTEM_NAME MATCHES "(Darwin|BSD|DragonFly)")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os")
|
||||||
@ -723,7 +728,7 @@ else()
|
|||||||
AND CMAKE_CXX_COMPILER_VERSION MATCHES "^9\\.")
|
AND CMAKE_CXX_COMPILER_VERSION MATCHES "^9\\.")
|
||||||
# Clang 9 has broken -ffast-math on glibc
|
# Clang 9 has broken -ffast-math on glibc
|
||||||
else()
|
else()
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MATH_FLAGS}")
|
||||||
endif()
|
endif()
|
||||||
endif(CMAKE_SYSTEM_NAME MATCHES "(Darwin|BSD|DragonFly)")
|
endif(CMAKE_SYSTEM_NAME MATCHES "(Darwin|BSD|DragonFly)")
|
||||||
set(CMAKE_CXX_FLAGS_SEMIDEBUG "-g -O1 -Wall -Wabi ${WARNING_FLAGS} ${OTHER_FLAGS}")
|
set(CMAKE_CXX_FLAGS_SEMIDEBUG "-g -O1 -Wall -Wabi ${WARNING_FLAGS} ${OTHER_FLAGS}")
|
||||||
|
@ -32,6 +32,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "util/timetaker.h"
|
#include "util/timetaker.h"
|
||||||
#include "profiler.h"
|
#include "profiler.h"
|
||||||
|
|
||||||
|
#ifdef __FAST_MATH__
|
||||||
|
#warning "-ffast-math is known to cause bugs in collision code, do not use!"
|
||||||
|
#endif
|
||||||
|
|
||||||
struct NearbyCollisionInfo {
|
struct NearbyCollisionInfo {
|
||||||
NearbyCollisionInfo(bool is_ul, bool is_obj, int bouncy,
|
NearbyCollisionInfo(bool is_ul, bool is_obj, int bouncy,
|
||||||
|
Loading…
Reference in New Issue
Block a user