]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cmake: make heap_profiler a library target
authorKefu Chai <kchai@redhat.com>
Thu, 26 Jul 2018 05:41:55 +0000 (13:41 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 26 Jul 2018 07:16:48 +0000 (15:16 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
CMakeLists.txt
src/CMakeLists.txt
src/mds/CMakeLists.txt
src/mon/CMakeLists.txt
src/osd/CMakeLists.txt
src/perfglue/CMakeLists.txt [new file with mode: 0644]

index 09d655525d4d148caa0af39056e15ff762f6dda8..74ed9a0ce952e31eaa7ce38e04deb00913a4feef 100644 (file)
@@ -315,6 +315,8 @@ if(ALLOCATOR)
   elseif(${ALLOCATOR} STREQUAL "jemalloc")
     find_package(JeMalloc REQUIRED)
     set(HAVE_JEMALLOC 1)
+  elseif(NOT ALLOCATOR STREQUAL "libc")
+    message(FATAL_ERROR "Unsupported allocator selected: ${ALLOCATOR}")
   endif()
 else(ALLOCATOR)
   find_package(gperftools)
index 87d76cdbeaa9e9e2a9ea2f77859797225f82b09a..40b5f9a84167cb600285ed9baf1d28b8dc983df0 100644 (file)
@@ -301,26 +301,14 @@ endif(HAVE_XIO)
 if(ALLOCATOR STREQUAL "tcmalloc")
   set(ALLOC_LIBS gperftools::tcmalloc)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free")
-  set(TCMALLOC_srcs perfglue/heap_profiler.cc)
 elseif(ALLOCATOR STREQUAL "tcmalloc_minimal")
   set(ALLOC_LIBS gperftools::tcmalloc_minimal)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free")
-  set(TCMALLOC_srcs perfglue/disabled_heap_profiler.cc)
 elseif(ALLOCATOR STREQUAL "jemalloc")
   set(ALLOC_LIBS JeMalloc::JeMalloc)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free")
-  set(TCMALLOC_srcs perfglue/disabled_heap_profiler.cc)
-elseif(ALLOCATOR STREQUAL "libc")
-  set(TCMALLOC_srcs perfglue/disabled_heap_profiler.cc)
-else()
-  set(TCMALLOC_srcs perfglue/disabled_heap_profiler.cc)
-  message(FATAL_ERROR "Unsupported allocator selected: ${ALLOCATOR}")
 endif()
 
-# tcmalloc heap profiler
-set(heap_profiler_files ${TCMALLOC_srcs})
-add_library(heap_profiler_objs OBJECT ${heap_profiler_files})
-
 if (WITH_BLKIN)
   add_subdirectory(blkin/blkin-lib)
 endif(WITH_BLKIN)
@@ -751,6 +739,9 @@ add_subdirectory(cls)
 # RADOS client/library
 add_subdirectory(osdc)
 
+# heal_profiler
+add_subdirectory(perfglue)
+
 add_library(rados_snap_set_diff_obj OBJECT librados/snap_set_diff.cc)
 
 add_subdirectory(include)
@@ -779,11 +770,12 @@ if (WITH_MGR)
       mgr/Mgr.cc
       mgr/Gil.cc
       mgr/mgr_commands.cc)
-  add_executable(ceph-mgr ${mgr_srcs}
-                 $<TARGET_OBJECTS:heap_profiler_objs>)
+  add_executable(ceph-mgr ${mgr_srcs})
   target_include_directories(ceph-mgr SYSTEM PRIVATE "${PYTHON_INCLUDE_DIRS}")
-  target_link_libraries(ceph-mgr osdc client global-static ceph-common
-      Boost::python ${MGR_PYTHON_LIBRARIES} ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS} ${ALLOC_LIBS})
+  target_link_libraries(ceph-mgr
+    osdc client heap_profiler
+    global-static ceph-common
+    Boost::python ${MGR_PYTHON_LIBRARIES} ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS} ${ALLOC_LIBS})
   install(TARGETS ceph-mgr DESTINATION bin)
 endif (WITH_MGR)
 
index e5acccc73ccc3d848528aaf700a623913d9e42ab..42220805e4e55338b24beff4efac8e390556117d 100644 (file)
@@ -42,6 +42,5 @@ set(mds_srcs
   ${CMAKE_SOURCE_DIR}/src/common/TrackedOp.cc
   ${CMAKE_SOURCE_DIR}/src/common/MemoryModel.cc
   ${CMAKE_SOURCE_DIR}/src/osdc/Journaler.cc)
-add_library(mds STATIC ${mds_srcs}
-  $<TARGET_OBJECTS:heap_profiler_objs>)
-target_link_libraries(mds ${ALLOC_LIBS} osdc liblua)
+add_library(mds STATIC ${mds_srcs})
+target_link_libraries(mds heap_profiler ${ALLOC_LIBS} osdc liblua)
index c8e2edbd7116b7fc755bf4e2f94ac5b10a4ad2c9..1f835a22c71581d94d550e1d9011e73bb92acb54 100644 (file)
@@ -25,6 +25,5 @@ set(lib_mon_srcs
   ../osd/OSDCap.cc)
 add_library(mon STATIC
   ${lib_mon_srcs}
-  $<TARGET_OBJECTS:kv_objs>
-  $<TARGET_OBJECTS:heap_profiler_objs>)
-target_link_libraries(mon ${ALLOC_LIBS})
+  $<TARGET_OBJECTS:kv_objs>)
+target_link_libraries(mon heap_profiler ${ALLOC_LIBS})
index 7ed2e736905ceaa898aef7af731ebb465bc85661..fa7d20dcac41eefbdbfb692e7959774df4e76495 100644 (file)
@@ -42,9 +42,10 @@ if(HAS_VTA)
 endif()
 add_library(osd STATIC ${osd_srcs}
   $<TARGET_OBJECTS:cls_references_objs>
-  $<TARGET_OBJECTS:global_common_objs>
-  $<TARGET_OBJECTS:heap_profiler_objs>)
-target_link_libraries(osd ${LEVELDB_LIBRARIES} dmclock ${CMAKE_DL_LIBS} ${ALLOC_LIBS})
+  $<TARGET_OBJECTS:global_common_objs>)
+target_link_libraries(osd
+  ${LEVELDB_LIBRARIES}
+  dmclock heap_profiler ${CMAKE_DL_LIBS} ${ALLOC_LIBS})
 if(WITH_LTTNG)
   add_dependencies(osd osd-tp pg-tp)
 endif()
diff --git a/src/perfglue/CMakeLists.txt b/src/perfglue/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f467209
--- /dev/null
@@ -0,0 +1,9 @@
+if(ALLOCATOR STREQUAL "tcmalloc")
+  add_library(heap_profiler STATIC
+    heap_profiler.cc)
+  target_link_libraries(heap_profiler
+    gperftools::tcmalloc)
+else()
+  add_library(heap_profiler STATIC
+    disabled_heap_profiler.cc)
+endif()