Add gprof profiling support. (#7547)

This commit is contained in:
Rossmaxx
2025-01-20 11:20:04 +05:30
committed by GitHub
parent b21a2696a9
commit 80a46d3c76
3 changed files with 20 additions and 2 deletions

View File

@@ -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,6 +665,22 @@ elseif(MSVC)
add_compile_options("/utf-8")
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)
endif()
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
function(add_sanitizer sanitizer supported_compilers want_flag status_flag)
if(${want_flag})
@@ -831,6 +848,7 @@ MESSAGE(
"* Debug using ThreadSanitizer : ${STATUS_DEBUG_TSAN}\n"
"* Debug using MemorySanitizer : ${STATUS_DEBUG_MSAN}\n"
"* Debug using UBSanitizer : ${STATUS_DEBUG_UBSAN}\n"
"* Profile using GNU profiler : ${STATUS_GPROF}\n"
)
MESSAGE(

View File

@@ -13,7 +13,7 @@ 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}
)
endif()

View File

@@ -6,7 +6,7 @@ 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")
endif()
FOREACH(_item ${PLUGIN_SOURCES})
GET_FILENAME_COMPONENT(_plugin "${_item}" NAME_WE)