]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake/modules/BuildSPDK.cmake: link whole-archive 44572/head
authorTongliang Deng <dengtongliang@gmail.com>
Thu, 13 Jan 2022 09:01:52 +0000 (17:01 +0800)
committerTongliang Deng <dengtongliang@gmail.com>
Thu, 20 Jan 2022 11:39:27 +0000 (19:39 +0800)
We build spdk as static library, linking against them requires the
use of `-Wl,--whole-archive` as argument, otherwise we will have error
`nvme.c: nvme_probe_internal: *ERROR*: NVMe trtype 256 not available`.
This is due to the use of constructor functions in spdk to register
NVMe transports. So we need to do so to ensure we call all the
constructors.

Signed-off-by: Tongliang Deng <dengtongliang@sensetime.com>
cmake/modules/BuildSPDK.cmake
src/blk/CMakeLists.txt

index 0a6acc8d059972fa93bae7bf1f12ec12264d64df..d6ce97e1d2e87c4c9552b34215745cac5425e211 100644 (file)
@@ -68,12 +68,14 @@ macro(build_spdk)
     add_dependencies(${spdk_lib} spdk-ext)
   endforeach()
 
-  set_target_properties(spdk::env_dpdk PROPERTIES
-    INTERFACE_LINK_LIBRARIES "dpdk::dpdk;rt")
-  set_target_properties(spdk::lvol PROPERTIES
-    INTERFACE_LINK_LIBRARIES spdk::util)
-  set_target_properties(spdk::util PROPERTIES
-    INTERFACE_LINK_LIBRARIES ${UUID_LIBRARIES})
   set(SPDK_INCLUDE_DIR "${source_dir}/include")
+  add_library(spdk::spdk INTERFACE IMPORTED)
+  add_dependencies(spdk::spdk
+    ${SPDK_LIBRARIES})
+  # workaround for https://review.spdk.io/gerrit/c/spdk/spdk/+/6798
+  set_target_properties(spdk::spdk PROPERTIES
+    INTERFACE_INCLUDE_DIRECTORIES ${SPDK_INCLUDE_DIR}
+    INTERFACE_LINK_LIBRARIES
+    "-Wl,--whole-archive $<JOIN:${spdk_libs}, > -Wl,--no-whole-archive;dpdk::dpdk;rt;${UUID_LIBRARIES}")
   unset(source_dir)
 endmacro()
index aaebc3c99f0f9713a0e4e49da1c97c3fb71c1785..37b9c0a410c8a7de2888e9c9bfa96989d76c8c43 100644 (file)
@@ -35,7 +35,8 @@ if(HAVE_LIBAIO)
 endif(HAVE_LIBAIO)
 
 if(WITH_SPDK)
-  target_link_libraries(blk PRIVATE ${SPDK_LIBRARIES})
+  target_link_libraries(blk
+    PRIVATE spdk::spdk)
 endif()
 
 if(WITH_ZBD)