Skip to content

Commit

Permalink
cmake: do not include global_context.cc multiple times
Browse files Browse the repository at this point in the history
otherwise ODR is violated:

==449025==ERROR: AddressSanitizer: odr-violation (0x000000f03700):
  [1] size=8 'g_ceph_context' ../src/global/global_context.cc:24:14
  [2] size=8 'g_ceph_context' ../src/global/global_context.cc:24:14
These globals were registered at these points:
  [1]:
    #0 0x4779bd in __asan_register_globals (/var/ssd/ceph/clang-build/bin/ceph-conf+0x4779bd)
    #1 0x56e9cb in asan.module_ctor (/var/ssd/ceph/clang-build/bin/ceph-conf+0x56e9cb)

  [2]:
    #0 0x4779bd in __asan_register_globals (/var/ssd/ceph/clang-build/bin/ceph-conf+0x4779bd)
    #1 0x7fe5fed12aeb in asan.module_ctor (/var/ssd/ceph/clang-build/lib/libceph-common.so.2+0x2f34aeb)

==449025==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0

Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov committed Jan 11, 2020
1 parent 387063a commit cd3cef7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ endif()
set(libcommon_files
${CMAKE_BINARY_DIR}/src/include/ceph_ver.h
ceph_ver.c
global/global_context.cc
xxHash/xxhash.c
log/Log.cc
mon/MonCap.cc
Expand Down Expand Up @@ -342,7 +343,6 @@ set(ceph_common_objs
$<TARGET_OBJECTS:compressor_objs>
$<TARGET_OBJECTS:common-objs>
$<TARGET_OBJECTS:common_mountcephfs_objs>
$<TARGET_OBJECTS:global_common_objs>
$<TARGET_OBJECTS:crush_objs>)
set(ceph_common_deps
json_spirit erasure_code arch crc32
Expand Down
4 changes: 2 additions & 2 deletions src/crimson/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ add_library(crimson-common STATIC
${PROJECT_SOURCE_DIR}/src/common/HeartbeatMap.cc
${PROJECT_SOURCE_DIR}/src/common/PluginRegistry.cc
${PROJECT_SOURCE_DIR}/src/common/RefCountedObj.cc
${PROJECT_SOURCE_DIR}/src/global/global_context.cc
${PROJECT_SOURCE_DIR}/src/global/pidfile.cc
${PROJECT_SOURCE_DIR}/src/librbd/Features.cc
${PROJECT_SOURCE_DIR}/src/log/Log.cc
Expand All @@ -96,8 +97,7 @@ add_library(crimson-common STATIC
$<TARGET_OBJECTS:crimson-auth>
$<TARGET_OBJECTS:common_buffer_obj>
$<TARGET_OBJECTS:common_mountcephfs_objs>
$<TARGET_OBJECTS:crimson-crush>
$<TARGET_OBJECTS:global_common_objs>)
$<TARGET_OBJECTS:crimson-crush>)

target_compile_definitions(crimson-common PRIVATE
"CEPH_LIBDIR=\"${CMAKE_INSTALL_FULL_LIBDIR}\""
Expand Down
9 changes: 2 additions & 7 deletions src/global/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ set(libglobal_srcs
global_init.cc
pidfile.cc
signal_handler.cc)
set(global_common_files
global_context.cc)
add_library(global_common_objs OBJECT ${global_common_files})
add_library(libglobal_objs OBJECT ${libglobal_srcs})

add_library(global-static STATIC
$<TARGET_OBJECTS:libglobal_objs>
$<TARGET_OBJECTS:global_common_objs>)
$<TARGET_OBJECTS:libglobal_objs>)
target_link_libraries(global-static common)

add_library(global STATIC
$<TARGET_OBJECTS:libglobal_objs>
$<TARGET_OBJECTS:global_common_objs>)
$<TARGET_OBJECTS:libglobal_objs>)
target_link_libraries(global ceph-common ${EXTRALIBS})
3 changes: 1 addition & 2 deletions src/osd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ if(HAS_VTA)
set_source_files_properties(osdcap.cc
PROPERTIES COMPILE_FLAGS -fno-var-tracking-assignments)
endif()
add_library(osd STATIC ${osd_srcs}
$<TARGET_OBJECTS:global_common_objs>)
add_library(osd STATIC ${osd_srcs})
target_link_libraries(osd
PUBLIC dmclock::dmclock
PRIVATE os heap_profiler cpu_profiler ${CMAKE_DL_LIBS})
Expand Down

0 comments on commit cd3cef7

Please sign in to comment.