From a5824d03e285b55a51887df217d303a4333b359c Mon Sep 17 00:00:00 2001 From: Alex Ainscow Date: Thu, 10 Jul 2025 12:44:54 +0100 Subject: [PATCH] cmake: link memstore against os This fixes the following linker error: FAILED: bin/ceph-monstore-tool : && /usr/lib64/ccache/clang++ -g -g -Wl,--export-dynamic -Xlinker --dependency-file=src/tools/CMakeFiles/ceph-monstore-tool.dir/link.d src/tools/CMakeFiles/ceph-monstore-tool.dir/ceph_monstore_tool.cc.o src/tools/CMakeFiles/ceph-monstore-tool.dir/__/auth/cephx/CephxKeyServer.cc.o src/tools/CMakeFiles/ceph-monstore-tool.dir/__/mgr/mgr_commands.cc.o -o bin/ceph-monstore-tool -Wl,-rpath,/work/ceph/build/lib: lib/libos.a lib/libglobal.a boost/lib/libboost_program_options.a lib/libmemstore.a lib/libkstore.a lib/libkv.a src/rocksdb/librocksdb.a /usr/lib64/libsnappy.so /usr/lib64/liblz4.so /usr/lib64/libz.so lib/libblk.a /lib64/libaio.so src/liburing/src/liburing.a lib/libheap_profiler.a /lib64/libtcmalloc.so lib/libfusestore.a /usr/lib64/libfuse.so lib/libceph-common.so.2 boost/lib/libboost_program_options.a lib/libfmtd.a src/opentelemetry-cpp/sdk/src/trace/libopentelemetry_trace.a src/opentelemetry-cpp/sdk/src/resource/libopentelemetry_resources.a src/opentelemetry-cpp/sdk/src/common/libopentelemetry_common.a src/opentelemetry-cpp/exporters/jaeger/libopentelemetry_exporter_jaeger_trace.a src/opentelemetry-cpp/ext/src/http/client/curl/libopentelemetry_http_client_curl.a /usr/lib64/libcurl.so /usr/lib64/libthrift.so lib/libjson_spirit.a lib/libcommon_utf8.a lib/liberasure_code.a lib/libextblkdev.a -lcap boost/lib/libboost_thread.a boost/lib/libboost_chrono.a boost/lib/libboost_atomic.a boost/lib/libboost_system.a boost/lib/libboost_random.a boost/lib/libboost_date_time.a boost/lib/libboost_iostreams.a boost/lib/libboost_regex.a /usr/lib64/libblkid.so /usr/lib64/libcrypto.so /usr/lib64/libudev.so /usr/lib64/libibverbs.so /usr/lib64/librdmacm.so /usr/lib64/libz.so src/breakpad_project-prefix/lib/libbreakpad_client.a -ldl /usr/lib64/librt.a -lresolv -Wl,--as-needed -latomic && : /opt/rh/gcc-toolset-14/root//usr/lib/gcc/x86_64-redhat-linux/14/../../../../bin/ld: lib/libmemstore.a(MemStore.cc.o): in function `MemStore::_do_transaction(ceph::os::Transaction&)': /work/ceph/src/os/memstore/MemStore.cc:992:(.text+0xa074): undefined reference to `ceph::os::Transaction::dump(ceph::Formatter*)' /opt/rh/gcc-toolset-14/root//usr/lib/gcc/x86_64-redhat-linux/14/../../../../bin/ld: lib/libmemstore.a(MemStore.cc.o): in function `ceph::os::Transaction::iterator::decode_attrset_bl(ceph::buffer::v15_2_0::list*)': /work/ceph/src/os/Transaction.h:753:(.text._ZN4ceph2os11Transaction8iterator17decode_attrset_blEPNS_6buffer7v15_2_04listE[_ZN4ceph2os11Transaction8iterator17decode_attrset_blEPNS_6buffer7v15_2_04listE]+0x1d): undefined reference to `decode_str_str_map_to_bl(ceph::buffer::v15_2_0::list::iterator_impl&, ceph::buffer::v15_2_0::list*)' /opt/rh/gcc-toolset-14/root//usr/lib/gcc/x86_64-redhat-linux/14/../../../../bin/ld: lib/libmemstore.a(MemStore.cc.o): in function `ceph::os::Transaction::iterator::decode_keyset_bl(ceph::buffer::v15_2_0::list*)': /work/ceph/src/os/Transaction.h:760:(.text._ZN4ceph2os11Transaction8iterator16decode_keyset_blEPNS_6buffer7v15_2_04listE[_ZN4ceph2os11Transaction8iterator16decode_keyset_blEPNS_6buffer7v15_2_04listE]+0x1d): undefined reference to `decode_str_set_to_bl(ceph::buffer::v15_2_0::list::iterator_impl&, ceph::buffer::v15_2_0::list*)' /opt/rh/gcc-toolset-14/root//usr/lib/gcc/x86_64-redhat-linux/14/../../../../bin/ld: lib/libmemstore.a(MemStore.cc.o): in function `ObjectStore::~ObjectStore()': /work/ceph/src/os/ObjectStore.h:248:(.text._ZN11ObjectStoreD2Ev[_ZN11ObjectStoreD2Ev]+0x13): undefined reference to `vtable for ObjectStore' /opt/rh/gcc-toolset-14/root//usr/lib/gcc/x86_64-redhat-linux/14/../../../../bin/ld: lib/libmemstore.a(MemStore.cc.o):(.data.rel.ro+0x1b0): undefined reference to `ObjectStore::write_meta(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&)' /opt/rh/gcc-toolset-14/root//usr/lib/gcc/x86_64-redhat-linux/14/../../../../bin/ld: lib/libmemstore.a(MemStore.cc.o):(.data.rel.ro+0x1b8): undefined reference to `ObjectStore::read_meta(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator >*)' /opt/rh/gcc-toolset-14/root//usr/lib/gcc/x86_64-redhat-linux/14/../../../../bin/ld: lib/libmemstore.a(MemStore.cc.o):(.data.rel.ro+0x2e8): undefined reference to `typeinfo for ObjectStore' clang++: error: linker command failed with exit code 1 (use -v to see invocation) [352/548] Linking CXX executable bin/crimson-osd ninja: build stopped: subcommand failed. The above shows that MemStore is not being correctly linked against os. I don't understand why this is not affecting most builds, but I can say it has been introduced after the T release was split. This change addresses a regression introduced by 5ab2e9fb. Fixes: https://tracker.ceph.com/issues/72078 Signed-off-by: Alex Ainscow --- src/os/memstore/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/os/memstore/CMakeLists.txt b/src/os/memstore/CMakeLists.txt index e59b64af7b4fa..ed4b85ece30d4 100644 --- a/src/os/memstore/CMakeLists.txt +++ b/src/os/memstore/CMakeLists.txt @@ -2,6 +2,7 @@ include(CheckCXXCompilerFlag) add_library(memstore MemStore.cc) +target_link_libraries(memstore PRIVATE os) check_cxx_compiler_flag("-Wno-maybe-uninitialized" HAS_WARNING_MAYBE_UNINITIALIZED) if(HAS_WARNING_MAYBE_UNINITIALIZED) -- 2.39.5