Skip to content

Commit

Permalink
cmake: do not link against profiler if gperftools is found
Browse files Browse the repository at this point in the history
this behaviour matches the autotools. and we should not enable profiling
unless asked to do so.

Fixes: http://tracker.ceph.com/issues/16804
Signed-off-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
tchaikov committed Jul 25, 2016
1 parent 07206f3 commit 8268d1b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
11 changes: 0 additions & 11 deletions CMakeLists.txt
Expand Up @@ -249,17 +249,6 @@ if(NOT ${ATOMIC_OPS_FOUND})
set(NO_ATOMIC_OPS 1)
endif(NOT ${ATOMIC_OPS_FOUND})

option(WITH_GPERFTOOLS "gperftools is here" ON)
if(${WITH_GPERFTOOLS})
find_package(gperftools)
set(HAVE_GPERFTOOLS ${GPERFTOOLS_FOUND})
if(${HAVE_GPERFTOOLS})
find_file(HAVE_GPERFTOOLS_HEAP_PROFILER_H heap-profiler.h PATHS /usr/include/gperftools)
find_file(HAVE_GPERFTOOLS_MALLOC_EXTENSION_H malloc_extension.h PATHS /usr/include/gperftools)
find_file(HAVE_GPERFTOOLS_PROFILER_H profiler.h PATHS /usr/include/gperftools)
endif(${HAVE_GPERFTOOLS})
endif(${WITH_GPERFTOOLS})

find_package(snappy REQUIRED)

#if allocator is set on command line make sure it matches below strings
Expand Down
18 changes: 12 additions & 6 deletions src/CMakeLists.txt
Expand Up @@ -201,9 +201,19 @@ set(EXTRALIBS uuid rt ${CMAKE_DL_LIBS} ${ATOMIC_OPS_LIBRARIES})

option(WITH_PROFILER "build extra profiler binaries" OFF)
if(WITH_PROFILER)
find_package(gperftools REQUIRED)
list(APPEND EXTRALIBS profiler)
endif(WITH_PROFILER)

if(WITH_PROFILER AND ALLOCATOR STREQUAL "tcmalloc")
find_file(HAVE_GPERFTOOLS_HEAP_PROFILER_H heap-profiler.h
PATHS ${GPERFTOOLS_INCLUDE_DIR})
find_file(HAVE_GPERFTOOLS_MALLOC_EXTENSION_H malloc_extension.h
PATHS ${GPERFTOOLS_INCLUDE_DIR})
find_file(HAVE_GPERFTOOLS_PROFILER_H profiler.h
PATHS ${GPERFTOOLS_INCLUDE_DIR})
endif()

if(${ENABLE_COVERAGE})
find_program(HAVE_GCOV gcov)
if(NOT HAVE_GCOV)
Expand Down Expand Up @@ -476,13 +486,13 @@ set(common_mountcephfs_files
add_library(common_mountcephfs_objs OBJECT
${common_mountcephfs_files})

if(WITH_PROFILER AND HAVE_GPERFTOOLS)
if(WITH_PROFILER)
list(APPEND libcommon_files
perfglue/cpu_profiler.cc)
else()
list(APPEND libcommon_files
perfglue/disabled_stubs.cc)
endif(WITH_PROFILER AND HAVE_GPERFTOOLS)
endif()

if(ENABLE_SHARED)
list(APPEND libcommon_files
Expand All @@ -499,10 +509,6 @@ set_source_files_properties(${CMAKE_SOURCE_DIR}/src/ceph_ver.c
${CMAKE_SOURCE_DIR}/src/test/encoding/ceph_dencoder.cc
APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/src/include/ceph_ver.h)

if(${HAVE_GPERFTOOLS})
target_link_libraries(common profiler)
endif(${HAVE_GPERFTOOLS})

if(HAVE_ARMV8_CRC)
add_library(common_crc_aarch64 STATIC common/crc32c_aarch64.c)
set_target_properties(common_crc_aarch64 PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} ${ARM_CRC_FLAGS}")
Expand Down

0 comments on commit 8268d1b

Please sign in to comment.