From ec18111bbcdf41ad37dcdd2bdf74a6c624b7101c Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Tue, 17 May 2022 01:09:30 +0200 Subject: [PATCH] Port CMake changes from dhewm3 (up to "Fix runtime assert on PPC OS X") - (Hopefully) better workaround for miscompiled cross products, #147 (-ffp-contract=off) - GCC/Clang: Remove -fno-unsafe-math-optimizations (redundant as long as -ffast-math isn't used) - Fix runtime assert on PPC OS X (-mone-byte-bool) --- CMakeLists.txt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a261556..553847d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,14 +138,17 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") set(CMAKE_C_FLAGS_DEBUG "-g -D_DEBUG -O0") set(CMAKE_C_FLAGS_DEBUGALL "-g -ggdb -D_DEBUG") set(CMAKE_C_FLAGS_PROFILE "-g -ggdb -D_DEBUG -O1 -fno-omit-frame-pointer") - set(CMAKE_C_FLAGS_RELEASE "-O2 -fno-unsafe-math-optimizations -fno-math-errno -fno-trapping-math -fomit-frame-pointer") - set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -ggdb -fno-unsafe-math-optimizations -fno-math-errno -fno-trapping-math -fno-omit-frame-pointer") - set(CMAKE_C_FLAGS_MINSIZEREL "-Os -fno-unsafe-math-optimizations -fno-math-errno -fno-trapping-math -fomit-frame-pointer") + set(CMAKE_C_FLAGS_RELEASE "-O2 -fno-math-errno -fno-trapping-math -fomit-frame-pointer") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -ggdb -fno-math-errno -fno-trapping-math -fno-omit-frame-pointer") + set(CMAKE_C_FLAGS_MINSIZEREL "-Os -fno-math-errno -fno-trapping-math -fomit-frame-pointer") set(CMAKE_CXX_FLAGS_DEBUGALL ${CMAKE_C_FLAGS_DEBUGALL}) set(CMAKE_CXX_FLAGS_PROFILE ${CMAKE_C_FLAGS_PROFILE}) add_compile_options(-fno-strict-aliasing) + # dear idiot compilers, don't fuck up math code with useless FMA "optimizations" + # (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100839) + add_compile_options(-ffp-contract=off) if(NOT AROS) CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden" cxx_has_fvisibility) @@ -198,8 +201,8 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") elseif(cpu STREQUAL "ppc") CHECK_CXX_COMPILER_FLAG("-arch ppc" cxx_has_arch_ppc) if(cxx_has_arch_ppc) - add_compile_options(-arch ppc) - set(ldflags "${ldflags} -arch ppc") + add_compile_options(-arch ppc -mone-byte-bool) + set(ldflags "${ldflags} -arch ppc -mone-byte-bool") endif() add_compile_options(-mmacosx-version-min=10.4)