From aa4014515784d28db6866eed0e8034b668aabb99 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Tue, 3 Jul 2018 15:20:31 +0200 Subject: [PATCH] Lower release build optimizations from -O3 to -O2. In the last few weeks I've played again through the game and kept an eye on small oddities. And there're a lot of them. For example some GUIs and videos getting stuck after the first frame (issue #192) or being unable to protect the guy with the lamp in Alpha Labs 3. Some digging proved that most - if not all - of these problems are caused by the compilers optimization level. When build with -O2 both g++ 8.1 and clang 6.0.0 are producing working code. g++ 8.1 with -O3 has some small, hard to notice oddities, clang 6.0.0 with -O3 shows a lot of them. Since there's not measurable difference between -O3 and -O2 just go down to the later: x doom_o3.txt + doom_o2.txt +----------------------------------------------------------------------+ | + | | + * | |x * x * | | |_____________________|___A______M__A_________M___|_|| +----------------------------------------------------------------------+ N Min Max Median Avg Stddev x 5 173 178 177 176.4 2.0736441 + 5 176 178 178 177.2 1.0954451 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4310301..c582660 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,8 +157,8 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") set(CMAKE_C_FLAGS_DEBUG "-g -D_DEBUG -O1") 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 "-O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") - set(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") + set(CMAKE_C_FLAGS_RELEASE "-O2 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O2 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") set(CMAKE_C_FLAGS_MINSIZEREL "-Os -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") set(CMAKE_CXX_FLAGS_DEBUGALL ${CMAKE_C_FLAGS_DEBUGALL})