From patchwork Thu Jul 26 18:47:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Williamson X-Patchwork-Id: 10546315 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 723EE112E for ; Thu, 26 Jul 2018 18:46:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 653262BC40 for ; Thu, 26 Jul 2018 18:46:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 574732BC29; Thu, 26 Jul 2018 18:46:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD0372BC29 for ; Thu, 26 Jul 2018 18:46:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730610AbeGZUES (ORCPT ); Thu, 26 Jul 2018 16:04:18 -0400 Received: from mx2.suse.de ([195.135.220.15]:37810 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729801AbeGZUES (ORCPT ); Thu, 26 Jul 2018 16:04:18 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 499D6AF6C; Thu, 26 Jul 2018 18:46:11 +0000 (UTC) Date: Thu, 26 Jul 2018 11:47:31 -0700 (PDT) From: Jesse Williamson X-X-Sender: jwilliamson@smaug To: ceph-devel cc: kefu chai Subject: libradosstriper linkage conundrum Message-ID: User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi folks, I'm working on a feature to make libradosstriper optional: https://github.com/ceph/ceph/pull/21983 While I believe I'm in the home stretch, I'm also getting a link error that I find mysterious. In the above PR, I have[1]: target_link_libraries(rados librados global ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS}) if(WITH_LIBRADOSSTRIPER) target_link_libraries(rados radosstriper) else(WITH_LIBRADOSSTRIPER) target_link_libraries(rados cls_lock_client) endif(WITH_LIBRADOSSTRIPER) ...notice the line linking in cls_lock_client. With this present, things look ok. Remove it, and for me this fails to compile (link errors follow text). It looks like cls_lock_client should already be linked into librados, as per src/librados/CMakeLists.txt: target_link_libraries(librados PRIVATE osdc ceph-common cls_lock_client ${BLKID_LIBRARIES} ${CRYPTO_LIBS} ${EXTRALIBS}) I wondered if it might have been related to name mangling (usually something I've seen when extern "C" is used and then another TU uses C++ linkage), but although the symbols in cls_lock_client.h are marked "export", that's the default linkage for C++ so I don't think there is anything in the source code. That leaves me to wonder if it's a cmake thing. Perhaps I'm missing something obvious? if(WITH_TESTS) 1) Compile with (note -DWITH_LIBRADOSSTRIPER=0) the following: ./do_cmake.sh -DHAS_VTA=0 -DWITH_LEVELDB=0 -DWITH_CCACHE=1 -DWITH_LTTNG=0 -DWITH_BABELTRACE=0 -DWITH_LZ4=0 -DWITH_LIBRADOSSTRIPER=0 cd build && make rados 2) I then see the errors listed below. Note that compiling with -DWITH_LIBRADOSSTRIPER=1, which is the default, should work just fine. Am I missing something obvious? Some cmake magic? I've had one other person not be able to reproduce this. Does it also work for everyone else (with -DWITH_LIBRADOSSTRIPER=0)? If so... what version of cmake are folks using? Appreciatively, -Jesse CMakeFiles/rados.dir/rados/rados.cc.o: In function `do_lock_cmd': /home/jwilliamson/work/ceph-libradosstriper/src/tools/rados/rados.cc:1246: undefined reference to `rados::cls::lock::get_lock_info(librados::IoCtx*, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, std::map, std::allocator > >*, ClsLockType*, std::__cxx11::basic_string, std::allocator >*)' /home/jwilliamson/work/ceph-libradosstriper/src/tools/rados/rados.cc:1309: undefined reference to `rados::cls::lock::Lock::break_lock(librados::IoCtx*, std::__cxx11::basic_string, std::allocator > const&, entity_name_t const&)' /home/jwilliamson/work/ceph-libradosstriper/src/tools/rados/rados.cc:1283: undefined reference to `rados::cls::lock::Lock::lock_shared(librados::IoCtx*, std::__cxx11::basic_string, std::allocator > const&)' /home/jwilliamson/work/ceph-libradosstriper/src/tools/rados/rados.cc:1286: undefined reference to `rados::cls::lock::Lock::lock_exclusive(librados::IoCtx*, std::__cxx11::basic_string, std::allocator > const&)' /home/jwilliamson/work/ceph-libradosstriper/src/tools/rados/rados.cc:1216: undefined reference to `rados::cls::lock::list_locks(librados::IoCtx*, std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::list, std::allocator >, std::allocator, std::allocator > > >*)' collect2: error: ld returned 1 exit status --- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html ==== To reproduce: 0) Make sure that "cls_lock_client" isn't included, by patching the above (as per Kefu): diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index ad8c2f81a1..b63654c09f 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -10,10 +10,10 @@ add_executable(rados ${rados_srcs}) target_link_libraries(rados librados global ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS}) if(WITH_LIBRADOSSTRIPER) -target_link_libraries(rados radosstriper) -else(WITH_LIBRADOSSTRIPER) -target_link_libraries(rados cls_lock_client) -endif(WITH_LIBRADOSSTRIPER) + target_link_libraries(rados radosstriper) + #else() + #target_link_libraries(rados cls_lock_client) +endif() install(TARGETS rados DESTINATION bin)