From 96e50f1b82ef6b47f2bf8548625500dc7b8e87cf Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Wed, 13 Apr 2022 15:42:21 +0200 Subject: [PATCH] cmake: resurrect mutex debugging in all Debug builds Commit 403f1ec2888a ("cmake: make "WITH_CEPH_DEBUG_MUTEX" depend on CMAKE_BUILD_TYPE") made WITH_CEPH_DEBUG_MUTEX depend on build type being set to Debug, in CMakeLists.txt. However, if CMAKE_BUILD_TYPE isn't specified by the user, we may still set it to Debug later, in src/CMakeLists.txt, and in that case WITH_CEPH_DEBUG_MUTEX doesn't get enabled. The result is that $ do_cmake.sh -DCMAKE_BUILD_TYPE=Debug ... debug builds have mutex debugging enabled, while $ do_cmake.sh ... builds, which are supposed to be the same, don't. Jenkins builders don't pass -DCMAKE_BUILD_TYPE=Debug so that commit effectively turned off all ceph_mutex_is_locked* asserts in "make check". Fixes: https://tracker.ceph.com/issues/55318 Signed-off-by: Ilya Dryomov (cherry picked from commit 226e614c95f1a1dcd79fa2011012ced1de19e6d3) --- CMakeLists.txt | 6 ++++++ src/CMakeLists.txt | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e46655beb983e..315281db9ddd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,12 @@ endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/") +if(NOT CMAKE_BUILD_TYPE AND EXISTS "${CMAKE_SOURCE_DIR}/.git") + set(default_build_type "Debug") + set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE + STRING "Default BUILD_TYPE is Debug, other options are: RelWithDebInfo, Release, and MinSizeRel." FORCE) +endif() + if(CMAKE_SYSTEM_NAME MATCHES "Linux") set(LINUX ON) FIND_PACKAGE(Threads) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 30cf3605468e7..83a90e4ecba6b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -158,12 +158,6 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) endif() endif(CMAKE_CXX_COMPILER_ID STREQUAL GNU) -if(NOT CMAKE_BUILD_TYPE AND EXISTS "${CMAKE_SOURCE_DIR}/.git") - set(default_build_type "Debug") - set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE - STRING "Default BUILD_TYPE is Debug, other options are: RelWithDebInfo, Release, and MinSizeRel." FORCE) -endif() - if(WITH_CEPH_DEBUG_MUTEX) add_compile_options($<$:-DCEPH_DEBUG_MUTEX>) endif() -- 2.39.5