From cd3cef7360245646a6f7690d5b4957846afb4534 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 11 Jan 2020 18:29:29 +0800 Subject: [PATCH] cmake: do not include global_context.cc multiple times 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 --- src/CMakeLists.txt | 2 +- src/crimson/CMakeLists.txt | 4 ++-- src/global/CMakeLists.txt | 9 ++------- src/osd/CMakeLists.txt | 3 +-- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 76a2be02ec9..7545df63bab 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 @@ -342,7 +343,6 @@ set(ceph_common_objs $ $ $ - $ $) set(ceph_common_deps json_spirit erasure_code arch crc32 diff --git a/src/crimson/CMakeLists.txt b/src/crimson/CMakeLists.txt index a373cb3ba51..25092fb84fe 100644 --- a/src/crimson/CMakeLists.txt +++ b/src/crimson/CMakeLists.txt @@ -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 @@ -96,8 +97,7 @@ add_library(crimson-common STATIC $ $ $ - $ - $) + $) target_compile_definitions(crimson-common PRIVATE "CEPH_LIBDIR=\"${CMAKE_INSTALL_FULL_LIBDIR}\"" diff --git a/src/global/CMakeLists.txt b/src/global/CMakeLists.txt index 704e0c7dc42..7da1911707d 100644 --- a/src/global/CMakeLists.txt +++ b/src/global/CMakeLists.txt @@ -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_link_libraries(global-static common) add_library(global STATIC - $ - $) + $) target_link_libraries(global ceph-common ${EXTRALIBS}) diff --git a/src/osd/CMakeLists.txt b/src/osd/CMakeLists.txt index f5368319e0c..c993ac2ff1b 100644 --- a/src/osd/CMakeLists.txt +++ b/src/osd/CMakeLists.txt @@ -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} - $) +add_library(osd STATIC ${osd_srcs}) target_link_libraries(osd PUBLIC dmclock::dmclock PRIVATE os heap_profiler cpu_profiler ${CMAKE_DL_LIBS}) -- 2.39.5