]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/libcephfs: copy DT_NEEDED entries from input libraries 62865/head
authorPatrick Donnelly <pdonnell@ibm.com>
Wed, 16 Apr 2025 20:24:23 +0000 (16:24 -0400)
committerPatrick Donnelly <pdonnell@ibm.com>
Wed, 14 May 2025 00:48:00 +0000 (20:48 -0400)
On Ubuntu 22.04, the linker is not stumbling thinking the libceph-common
library is missing on the command-line. This appears to be a bug and the only
workaround I've found is to copy the DT_NEEDED entries for the input shared
objects (which is traditional linker behavior). I don't have an explanation for
why this occurs only for a few test executables.

Fixes: https://tracker.ceph.com/issues/70498
Signed-off-by: Patrick Donnelly <pdonnell@ibm.com>
src/test/libcephfs/CMakeLists.txt

index 8ad73529fea12e0e58fbccedf5478a96b7d41f41..2573fa08f66c9452418604d0228fcff703b2b7f9 100644 (file)
@@ -1,3 +1,21 @@
+# Note:
+#
+#    target_link_options(ceph_test_libcephfs PRIVATE -Wl,--copy-dt-needed-entries)
+#
+# This is done due to this linker error:
+#
+#    FAILED: bin/ceph_test_libcephfs_newops
+#    : && /usr/bin/g++-11 -Og -g -rdynamic -pie src/test/libcephfs/CMakeFiles/ceph_test_libcephfs_newops.dir/main.cc.o src/test/libcephfs/CMakeFiles/ceph_test_libcephfs_newops.dir/newops.cc.o -o bin/ceph_test_libcephfs_newops  -Wl,-rpath,/home/ubuntu/ceph/build/lib:  lib/libcephfs.so.2.0.0  lib/libgmock_main.a  lib/libgmock.a  lib/libgtest.a  -ldl  -ldl  /usr/lib/x86_64-linux-gnu/librt.a  -lresolv  -ldl  lib/libceph-common.so.2  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_program_options.a  boost/lib/libboost_date_time.a  boost/lib/libboost_iostreams.a  boost/lib/libboost_regex.a  lib/libfmtd.a  /usr/lib/x86_64-linux-gnu/libblkid.so  /usr/lib/x86_64-linux-gnu/libcrypto.so  /usr/lib/x86_64-linux-gnu/libudev.so  /usr/lib/x86_64-linux-gnu/libz.so  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/lib/x86_64-linux-gnu/libcurl.so  /usr/lib/x86_64-linux-gnu/libthrift.so  -lresolv  -ldl   -Wl,--as-needed -latomic && :
+#    /usr/bin/ld: lib/libcephfs.so.2.0.0: undefined reference to symbol '_ZN4ceph18__ceph_assert_failERKNS_11assert_dataE'
+#    /usr/bin/ld: lib/libceph-common.so.2: error adding symbols: DSO missing from command line
+#    collect2: error: ld returned 1 exit status
+#
+# Despite the presence of libceph-common.so.2 on the linker invocation, this
+# error persists. I (Patrick) have not found a resolution for this except to
+# make the linker behave in traditional manner where library dependencies are
+# assumed to be available. It seems like a linker bug and I have no explanation
+# for why it only affects a few test executables.
+
 if(WITH_LIBCEPHFS)
   add_executable(ceph_test_libcephfs
     test.cc
@@ -19,6 +37,9 @@ if(WITH_LIBCEPHFS)
     ${EXTRALIBS}
     ${CMAKE_DL_LIBS}
     )
+  if(NOT WIN32)
+    target_link_options(ceph_test_libcephfs PRIVATE -Wl,--copy-dt-needed-entries)
+  endif()
   install(TARGETS ceph_test_libcephfs
     DESTINATION ${CMAKE_INSTALL_BINDIR})
 
@@ -33,6 +54,9 @@ if(WITH_LIBCEPHFS)
     ${EXTRALIBS}
     ${CMAKE_DL_LIBS}
     )
+  if(NOT WIN32)
+    target_link_options(ceph_test_libcephfs_snapdiff PRIVATE -Wl,--copy-dt-needed-entries)
+  endif()
   install(TARGETS ceph_test_libcephfs_snapdiff
     DESTINATION ${CMAKE_INSTALL_BINDIR})
 
@@ -47,6 +71,9 @@ if(WITH_LIBCEPHFS)
     ${EXTRALIBS}
     ${CMAKE_DL_LIBS}
     )
+  if(NOT WIN32)
+    target_link_options(ceph_test_libcephfs_suidsgid PRIVATE -Wl,--copy-dt-needed-entries)
+  endif()
   install(TARGETS ceph_test_libcephfs_suidsgid
     DESTINATION ${CMAKE_INSTALL_BINDIR})
 
@@ -57,11 +84,13 @@ if(WITH_LIBCEPHFS)
   target_link_libraries(ceph_test_libcephfs_vxattr
     ceph-common
     cephfs
-    librados
     ${UNITTEST_LIBS}
     ${EXTRALIBS}
     ${CMAKE_DL_LIBS}
     )
+  if(NOT WIN32)
+    target_link_options(ceph_test_libcephfs_vxattr PRIVATE -Wl,--copy-dt-needed-entries)
+  endif()
   install(TARGETS ceph_test_libcephfs_vxattr
     DESTINATION ${CMAKE_INSTALL_BINDIR})
 
@@ -76,6 +105,9 @@ if(WITH_LIBCEPHFS)
     ${EXTRALIBS}
     ${CMAKE_DL_LIBS}
     )
+  if(NOT WIN32)
+    target_link_options(ceph_test_libcephfs_newops PRIVATE -Wl,--copy-dt-needed-entries)
+  endif()
   install(TARGETS ceph_test_libcephfs_newops
     DESTINATION ${CMAKE_INSTALL_BINDIR})
 
@@ -84,13 +116,16 @@ if(WITH_LIBCEPHFS)
     add_executable(ceph_test_libcephfs_reclaim
       reclaim.cc
     )
-  target_link_libraries(ceph_test_libcephfs_reclaim
+    target_link_libraries(ceph_test_libcephfs_reclaim
       ceph-common
       cephfs
       ${UNITTEST_LIBS}
       ${EXTRALIBS}
       ${CMAKE_DL_LIBS}
-      )
+    )
+    if(NOT WIN32)
+      target_link_options(ceph_test_libcephfs_reclaim PRIVATE -Wl,--copy-dt-needed-entries)
+    endif()
     install(TARGETS ceph_test_libcephfs_reclaim
       DESTINATION ${CMAKE_INSTALL_BINDIR})
   endif(NOT WIN32)
@@ -98,14 +133,16 @@ if(WITH_LIBCEPHFS)
   add_executable(ceph_test_libcephfs_lazyio
     lazyio.cc
   )
-target_link_libraries(ceph_test_libcephfs_lazyio
-    ceph-common
+  target_link_libraries(ceph_test_libcephfs_lazyio
     cephfs
     librados
     ${UNITTEST_LIBS}
     ${EXTRALIBS}
     ${CMAKE_DL_LIBS}
-    )   
+  )
+  if(NOT WIN32)
+    target_link_options(ceph_test_libcephfs_lazyio PRIVATE -Wl,--copy-dt-needed-entries)
+  endif()
   install(TARGETS ceph_test_libcephfs_lazyio
     DESTINATION ${CMAKE_INSTALL_BINDIR})
 
@@ -119,7 +156,10 @@ target_link_libraries(ceph_test_libcephfs_lazyio
     ${UNITTEST_LIBS}
     ${EXTRALIBS}
     ${CMAKE_DL_LIBS}
-    )
+  )
+  if(NOT WIN32)
+    target_link_options(ceph_test_libcephfs_access PRIVATE -Wl,--copy-dt-needed-entries)
+  endif()
   install(TARGETS ceph_test_libcephfs_access
     DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif(WITH_LIBCEPHFS)