From 19790d7541d835d909659efe5b8bf31c4b664d42 Mon Sep 17 00:00:00 2001 From: Rossmaxx Date: Thu, 17 Oct 2024 16:14:44 +0530 Subject: [PATCH 01/11] disable -fomit-frame-pointer for release builds --- plugins/LadspaEffect/swh/CMakeLists.txt | 6 +++++- plugins/LadspaEffect/tap/CMakeLists.txt | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/LadspaEffect/swh/CMakeLists.txt b/plugins/LadspaEffect/swh/CMakeLists.txt index 203c3168f77..4cce4b3b85d 100644 --- a/plugins/LadspaEffect/swh/CMakeLists.txt +++ b/plugins/LadspaEffect/swh/CMakeLists.txt @@ -13,9 +13,13 @@ ENDIF() # Additional compile flags if(NOT MSVC) set(COMPILE_FLAGS ${COMPILE_FLAGS} -O3 -c - -fomit-frame-pointer -funroll-loops -ffast-math -fno-strict-aliasing + -funroll-loops -ffast-math -fno-strict-aliasing ${PIC_FLAGS} ) + # an optimisation flag, but makes it harder to debug + if(CMAKE_BUILD_TYPE STREQUAL "Release") + set(COMPILE_FLAGS ${COMPILE_FLAGS} -fomit-frame-pointer) + endif() endif() # Loop over every XML file diff --git a/plugins/LadspaEffect/tap/CMakeLists.txt b/plugins/LadspaEffect/tap/CMakeLists.txt index 84c4694655f..81ce22450da 100644 --- a/plugins/LadspaEffect/tap/CMakeLists.txt +++ b/plugins/LadspaEffect/tap/CMakeLists.txt @@ -6,7 +6,12 @@ LIST(SORT PLUGIN_SOURCES) if(MSVC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fp:fast") else() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -fomit-frame-pointer -fno-strict-aliasing -funroll-loops -ffast-math") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -fno-strict-aliasing -funroll-loops -ffast-math") + + # an optimisation flag, but makes it harder to debug + if(CMAKE_BUILD_TYPE STREQUAL "Release") + set(COMPILE_FLAGS "${COMPILE_FLAGS} -fomit-frame-pointer") + endif() endif() FOREACH(_item ${PLUGIN_SOURCES}) GET_FILENAME_COMPONENT(_plugin "${_item}" NAME_WE) From 420fb9fef12473ce83248b1a12649bc4192fb695 Mon Sep 17 00:00:00 2001 From: Rossmaxx Date: Thu, 17 Oct 2024 16:20:08 +0530 Subject: [PATCH 02/11] add gprof flag --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bb4adc4aa8..7a8d9295bee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -664,6 +664,13 @@ elseif(MSVC) add_compile_options("/utf-8") ENDIF() +# gcc builds support gprof for profiling, should not be used for release builds because +# -fomit-frame-pointer clashes with -pg +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND NOT CMAKE_BUILD_TYPE STREQUAL "Release") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") +endif() + # add enabled sanitizers function(add_sanitizer sanitizer supported_compilers want_flag status_flag) if(${want_flag}) From b20383326b085ec53a9e7900dfcdd778fdee7611 Mon Sep 17 00:00:00 2001 From: Rossmaxx Date: Fri, 18 Oct 2024 14:05:25 +0530 Subject: [PATCH 03/11] use cmake options --- CMakeLists.txt | 17 ++++++++++++----- plugins/LadspaEffect/swh/CMakeLists.txt | 2 +- plugins/LadspaEffect/tap/CMakeLists.txt | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a8d9295bee..85533715ba1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,6 +102,7 @@ option(WANT_DEBUG_ASAN "Enable AddressSanitizer" OFF) option(WANT_DEBUG_TSAN "Enable ThreadSanitizer" OFF) option(WANT_DEBUG_MSAN "Enable MemorySanitizer" OFF) option(WANT_DEBUG_UBSAN "Enable UndefinedBehaviorSanitizer" OFF) +option(WANT_DEBUG_GPROF "Enable gprof profiler" OFF) OPTION(BUNDLE_QT_TRANSLATIONS "Install Qt translation files for LMMS" OFF) @@ -664,11 +665,16 @@ elseif(MSVC) add_compile_options("/utf-8") ENDIF() -# gcc builds support gprof for profiling, should not be used for release builds because -# -fomit-frame-pointer clashes with -pg -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND NOT CMAKE_BUILD_TYPE STREQUAL "Release") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") +# gcc builds support gprof for profiling +if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU") + set("${STATUS_GPROF}" "NOT SUPPORTED ON THIS PLATFORM") + set(WANT_DEBUG_GPROF OFF) +endif() + +if(WANT_DEBUG_GPROF) + add_compile_options(-pg) + add_link_options(-pg) + set("${STATUS_GPROF}" "OK") endif() # add enabled sanitizers @@ -838,6 +844,7 @@ MESSAGE( "* Debug using ThreadSanitizer : ${STATUS_DEBUG_TSAN}\n" "* Debug using MemorySanitizer : ${STATUS_DEBUG_MSAN}\n" "* Debug using UBSanitizer : ${STATUS_DEBUG_UBSAN}\n" +"* Profiling using GNU profiler : ${STATUS_GPROF}\n" ) MESSAGE( diff --git a/plugins/LadspaEffect/swh/CMakeLists.txt b/plugins/LadspaEffect/swh/CMakeLists.txt index 4cce4b3b85d..4cef78e32eb 100644 --- a/plugins/LadspaEffect/swh/CMakeLists.txt +++ b/plugins/LadspaEffect/swh/CMakeLists.txt @@ -17,7 +17,7 @@ if(NOT MSVC) ${PIC_FLAGS} ) # an optimisation flag, but makes it harder to debug - if(CMAKE_BUILD_TYPE STREQUAL "Release") + if(NOT WANT_DEBUG_GPROF) set(COMPILE_FLAGS ${COMPILE_FLAGS} -fomit-frame-pointer) endif() endif() diff --git a/plugins/LadspaEffect/tap/CMakeLists.txt b/plugins/LadspaEffect/tap/CMakeLists.txt index 81ce22450da..82502a4541b 100644 --- a/plugins/LadspaEffect/tap/CMakeLists.txt +++ b/plugins/LadspaEffect/tap/CMakeLists.txt @@ -9,7 +9,7 @@ else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -fno-strict-aliasing -funroll-loops -ffast-math") # an optimisation flag, but makes it harder to debug - if(CMAKE_BUILD_TYPE STREQUAL "Release") + if(NOT WANT_DEBUG_GPROF) set(COMPILE_FLAGS "${COMPILE_FLAGS} -fomit-frame-pointer") endif() endif() From 156cb413cdbeb417ae418fa2022db401b10a0960 Mon Sep 17 00:00:00 2001 From: Rossmaxx Date: Fri, 18 Oct 2024 14:08:13 +0530 Subject: [PATCH 04/11] fixup --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 85533715ba1..acc4d74f7c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -667,7 +667,7 @@ ENDIF() # gcc builds support gprof for profiling if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU") - set("${STATUS_GPROF}" "NOT SUPPORTED ON THIS PLATFORM") + set("${STATUS_GPROF}" ", NOT SUPPORTED ON THIS PLATFORM") set(WANT_DEBUG_GPROF OFF) endif() @@ -675,6 +675,8 @@ if(WANT_DEBUG_GPROF) add_compile_options(-pg) add_link_options(-pg) set("${STATUS_GPROF}" "OK") +else() + set("${STATUS_GPROF}" "DISABLED ${STATUS_GPROF}") endif() # add enabled sanitizers @@ -844,7 +846,7 @@ MESSAGE( "* Debug using ThreadSanitizer : ${STATUS_DEBUG_TSAN}\n" "* Debug using MemorySanitizer : ${STATUS_DEBUG_MSAN}\n" "* Debug using UBSanitizer : ${STATUS_DEBUG_UBSAN}\n" -"* Profiling using GNU profiler : ${STATUS_GPROF}\n" +"* Profiling using GNU profiler : ${STATUS_GPROF}\n" ) MESSAGE( From 079574a2fe9e0cdd523f4c37ef27547fc4803ffb Mon Sep 17 00:00:00 2001 From: Rossmaxx Date: Fri, 18 Oct 2024 14:13:20 +0530 Subject: [PATCH 05/11] fixed text message --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index acc4d74f7c4..a78914d2837 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -667,16 +667,16 @@ ENDIF() # gcc builds support gprof for profiling if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU") - set("${STATUS_GPROF}" ", NOT SUPPORTED ON THIS PLATFORM") + set(STATUS_GPROF", NOT SUPPORTED ON THIS PLATFORM") set(WANT_DEBUG_GPROF OFF) endif() if(WANT_DEBUG_GPROF) add_compile_options(-pg) add_link_options(-pg) - set("${STATUS_GPROF}" "OK") + set(STATUS_GPROF "OK") else() - set("${STATUS_GPROF}" "DISABLED ${STATUS_GPROF}") + set(STATUS_GPROF "DISABLED ${STATUS_GPROF}") endif() # add enabled sanitizers From 858d4852957bdd22dabe7d8747ccd990f50bbcb8 Mon Sep 17 00:00:00 2001 From: Rossmaxx Date: Fri, 18 Oct 2024 14:23:16 +0530 Subject: [PATCH 06/11] missed this space --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a78914d2837..7465e553c6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -667,7 +667,7 @@ ENDIF() # gcc builds support gprof for profiling if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU") - set(STATUS_GPROF", NOT SUPPORTED ON THIS PLATFORM") + set(STATUS_GPROF ", NOT SUPPORTED ON THIS PLATFORM") set(WANT_DEBUG_GPROF OFF) endif() From 8944cbcfc6999f504f8a6754bf9164bb0e19356c Mon Sep 17 00:00:00 2001 From: Rossmaxx Date: Sun, 20 Oct 2024 20:20:06 +0530 Subject: [PATCH 07/11] remove -fomit-frame-pointer --- plugins/LadspaEffect/swh/CMakeLists.txt | 4 ---- plugins/LadspaEffect/tap/CMakeLists.txt | 5 ----- 2 files changed, 9 deletions(-) diff --git a/plugins/LadspaEffect/swh/CMakeLists.txt b/plugins/LadspaEffect/swh/CMakeLists.txt index 4cef78e32eb..27796cc9dd7 100644 --- a/plugins/LadspaEffect/swh/CMakeLists.txt +++ b/plugins/LadspaEffect/swh/CMakeLists.txt @@ -16,10 +16,6 @@ if(NOT MSVC) -funroll-loops -ffast-math -fno-strict-aliasing ${PIC_FLAGS} ) - # an optimisation flag, but makes it harder to debug - if(NOT WANT_DEBUG_GPROF) - set(COMPILE_FLAGS ${COMPILE_FLAGS} -fomit-frame-pointer) - endif() endif() # Loop over every XML file diff --git a/plugins/LadspaEffect/tap/CMakeLists.txt b/plugins/LadspaEffect/tap/CMakeLists.txt index 82502a4541b..93b54ae47ff 100644 --- a/plugins/LadspaEffect/tap/CMakeLists.txt +++ b/plugins/LadspaEffect/tap/CMakeLists.txt @@ -7,11 +7,6 @@ if(MSVC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fp:fast") else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -fno-strict-aliasing -funroll-loops -ffast-math") - - # an optimisation flag, but makes it harder to debug - if(NOT WANT_DEBUG_GPROF) - set(COMPILE_FLAGS "${COMPILE_FLAGS} -fomit-frame-pointer") - endif() endif() FOREACH(_item ${PLUGIN_SOURCES}) GET_FILENAME_COMPONENT(_plugin "${_item}" NAME_WE) From 8c4bdea8d63b70578857b5bcd5f52d3bb9a3578f Mon Sep 17 00:00:00 2001 From: Rossmaxx Date: Wed, 13 Nov 2024 14:33:54 +0530 Subject: [PATCH 08/11] address review from dom --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7465e553c6e..c56c5a4a993 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -667,7 +667,7 @@ ENDIF() # gcc builds support gprof for profiling if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU") - set(STATUS_GPROF ", NOT SUPPORTED ON THIS PLATFORM") + set(STATUS_GPROF ", NOT SUPPORTED BY THIS COMPILER") set(WANT_DEBUG_GPROF OFF) endif() @@ -846,7 +846,7 @@ MESSAGE( "* Debug using ThreadSanitizer : ${STATUS_DEBUG_TSAN}\n" "* Debug using MemorySanitizer : ${STATUS_DEBUG_MSAN}\n" "* Debug using UBSanitizer : ${STATUS_DEBUG_UBSAN}\n" -"* Profiling using GNU profiler : ${STATUS_GPROF}\n" +"* Profile using GNU profiler : ${STATUS_GPROF}\n" ) MESSAGE( From 0256dcf5a4d8523e5a159738e20efafcbf5e35c4 Mon Sep 17 00:00:00 2001 From: Rossmaxx Date: Wed, 13 Nov 2024 14:38:03 +0530 Subject: [PATCH 09/11] add clang to the list --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c56c5a4a993..9124ce3fa46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -665,8 +665,8 @@ elseif(MSVC) add_compile_options("/utf-8") ENDIF() -# gcc builds support gprof for profiling -if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU") +# gcc/clang builds support gprof for profiling +if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|CLANG") set(STATUS_GPROF ", NOT SUPPORTED BY THIS COMPILER") set(WANT_DEBUG_GPROF OFF) endif() From 03e817b4852b09486c263fb03bc9df835753abb3 Mon Sep 17 00:00:00 2001 From: Rossmaxx Date: Wed, 20 Nov 2024 14:29:00 +0530 Subject: [PATCH 10/11] Revert "add clang to the list" This reverts commit 0256dcf5a4d8523e5a159738e20efafcbf5e35c4. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9124ce3fa46..c56c5a4a993 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -665,8 +665,8 @@ elseif(MSVC) add_compile_options("/utf-8") ENDIF() -# gcc/clang builds support gprof for profiling -if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|CLANG") +# gcc builds support gprof for profiling +if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU") set(STATUS_GPROF ", NOT SUPPORTED BY THIS COMPILER") set(WANT_DEBUG_GPROF OFF) endif() From 656268629b7ec4ced4385b8ed3071a00340ca367 Mon Sep 17 00:00:00 2001 From: Rossmaxx Date: Sun, 8 Dec 2024 12:42:24 +0530 Subject: [PATCH 11/11] add clarification comment for clang --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c56c5a4a993..3d1da80c98c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -666,6 +666,8 @@ elseif(MSVC) ENDIF() # gcc builds support gprof for profiling +# clang too seems to support gprof, but i couldn't get it working. +# if needed, change the if condition to "GNU|CLANG" if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU") set(STATUS_GPROF ", NOT SUPPORTED BY THIS COMPILER") set(WANT_DEBUG_GPROF OFF)