[yoshimi] ...another minor itch

  • From: Ichthyostega <prg@xxxxxxxxxxxxxxx>
  • To: yoshimi@xxxxxxxxxxxxx
  • Date: Sun, 27 May 2018 17:30:54 +0200


Hello Will,

just another minor problem I noticed when setting yoshimi as a local dev project
to be able to step through with the debugger.

The CMake-Build defines a "BuildForDebug" toggle, but does not actually use the
corresponding flags defined in "BuildOptionsDebug".

And while we at it, I'd also propose to include the flags
"-ffast-math -fno-finite-math-only" in the default for "BuildOptionsDebug".

My resoning is: --fast-math allows to emit code which behaves (for performance
reasons) slightly different with respect to the IEEE floating point standard.
And I think, it would be pointless to build a executable for debugging, which
yields slightly different (in this case totally IEEE compliant) numeric values.
This looks like a insidious pitfall for anyone investigating Yoshimi's behaviour
in the debugger.

What's your opinion towards this one?

Greetings,
Hermann




From b5e4c3ba2242b0bffa3a4df0914308dcc633ee6f Mon Sep 17 00:00:00 2001
From: Ichthyostega <prg@xxxxxxxxxxxxxxx>
Date: Sun, 27 May 2018 15:16:20 +0200
Subject: [PATCH] Bugfix CMake-Build: actually use the debug compiler flags

...and provide a sensible default.
Since all release targets use -ffast-math -fno-finite-math-only
it would be highly confusing /not/ to set that very options also for
a debug build. Otherwise you'd observe slightly different floating point
values in the debug build, which defeats the whole purpose of such a build.
---
 src/CMakeLists.txt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1687492b..860d0241 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -80,7 +80,7 @@ option (BuildForAMD_X86_64 "Build for AMD x86_64 system" OFF)
 option (BuildForCore2_X86_64 "Build for Intel Core2 x86_64 system" OFF)
 option (BuildForNEON "Build for ARM Cortex A9 system" OFF)
 option (BuildForThisCPU "Build for presently running system" OFF)
-option (BuildForDebug "Include gdb debugging support" OFF)
+option (BuildForDebug "Debug build without optimisation.  Enable gdb debugging 
support. Overrides all other platform options." OFF)
 
 #option to build lv2 plugin
 option (LV2Plugin "Build yoshimi lv2 plugin interface" ON)
@@ -122,7 +122,7 @@ set (BuildOptionsBasic
 )
 
 set (BuildOptionsDebug
-    "-O0 -g3 -ggdb -Wall -Wpointer-arith" CACHE STRING "Debug build flags")
+    "-O0 -g3 -ggdb -Wall -Wpointer-arith -ffast-math -fno-finite-math-only" 
CACHE STRING "Debug build flags")
 
 find_package (PkgConfig REQUIRED)
 if (PKG_CONFIG_FOUND)
@@ -303,6 +303,7 @@ set (YOSHI_INCLUDES ${FLTK_INCLUDE_DIR})
 
 if (BuildForDebug)
     set (CMAKE_BUILD_TYPE "Debug")
+    set (CMAKE_CXX_FLAGS_DEBUG ${BuildOptionsDebug})
     message (STATUS "Building for ${CMAKE_BUILD_TYPE}, flags: 
${CMAKE_CXX_FLAGS_DEBUG}")
 else (BuildForDebug)
     set (CMAKE_BUILD_TYPE "Release")
-- 
2.11.0

Other related posts: