From: Kefu Chai Date: Fri, 16 Jul 2021 02:37:23 +0000 (+0800) Subject: cmake: add "-Og" to CMAKE_C_FLAGS_DEBUG X-Git-Tag: v17.1.0~1347^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8e742424a7f9f5204bee435ca8609e93f648ef77;p=ceph.git cmake: add "-Og" to CMAKE_C_FLAGS_DEBUG without specifying -Og, -O0 is used. as per https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html > -O0 > Reduce compilation time and make debugging produce the expected > results. This is the default. and > -Og > Optimize debugging experience. -Og should be the optimization level of > choice for the standard edit-compile-debug cycle, offering a reasonable > level of optimization while maintaining fast compilation and a good > debugging experience. It is a better choice than -O0 for producing > debuggable code because some compiler passes that collect debug > information are disabled at -O0. and Debug is the default built type if .git directory is found under the root source directory, so by adding "-Og -g" to CMAKE_C_FLAGS_DEBUG, developers can have better debugging experience when testing Ceph built from a git repo. but the downside is that it might take longer to build the tree. this change should also enable us to link crimson on aarch64. the same applies to Clang, > -O0 Means “no optimization”: this level compiles the fastest and generates the most debuggable code. > -O1 Somewhere between -O0 and -O2. > -O2 Moderate level of optimization which enables most optimizations. > -Og Like -O1. In future versions, this option might disable different optimizations in order to improve debuggability. see https://clang.llvm.org/docs/CommandGuide/clang.html#cmdoption-o0 see also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101448 Fixes: https://tracker.ceph.com/issues/51441 Signed-off-by: Kefu Chai --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 749c29402c89..b72d916d1983 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -121,6 +121,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) else() string(APPEND CMAKE_EXE_LINKER_FLAGS " -rdynamic") endif() + string(APPEND CMAKE_CXX_FLAGS_DEBUG " -Og") add_compile_options($<$:-Wstrict-null-sentinel>) add_compile_options($<$:-Woverloaded-virtual>) add_compile_options($<$:-fno-new-ttp-matching>) @@ -134,6 +135,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_EXPORTS_C_FLAG}") string(APPEND CMAKE_LINKER_FLAGS " -rdynamic -export-dynamic ${CMAKE_EXE_EXPORTS_C_FLAG}") + string(APPEND CMAKE_CXX_FLAGS_DEBUG " -g") add_compile_options($<$:-Wno-inconsistent-missing-override>) add_compile_options($<$:-Wno-mismatched-tags>) add_compile_options($<$:-Wno-unused-private-field>)