From 3c3824a3d24d52fb6841b43120e4fb790f0cf2df Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 27 Oct 2016 09:25:27 -0700 Subject: [PATCH] nvmf_tgt: add list of libs that need whole-archive Some of the SPDK libraries only expose constructor functions, so they would normally be eliminted by the linker. Add a new list in the Makefile of libraries that must be linked with --whole-archive (while still being added to the dependency list for the app). Change-Id: I7e41a807c945468730fa84f1bdee23dfd6b59358 Signed-off-by: Daniel Verkamp --- app/nvmf_tgt/Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/nvmf_tgt/Makefile b/app/nvmf_tgt/Makefile index 86580f12b..2335b2de0 100644 --- a/app/nvmf_tgt/Makefile +++ b/app/nvmf_tgt/Makefile @@ -54,6 +54,10 @@ SPDK_LIBS = \ $(SPDK_ROOT_DIR)/lib/rpc/libspdk_rpc.a \ $(SPDK_ROOT_DIR)/lib/jsonrpc/libspdk_jsonrpc.a \ $(SPDK_ROOT_DIR)/lib/json/libspdk_json.a \ + +# These libraries do not expose any external API, only constructors, +# so they must be linked specially to ensure they are not removed. +SPDK_WHOLE_LIBS = \ $(SPDK_ROOT_DIR)/lib/event/rpc/libspdk_app_rpc.a \ $(SPDK_ROOT_DIR)/lib/log/rpc/libspdk_log_rpc.a \ @@ -62,6 +66,8 @@ LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \ LIBS += $(SPDK_LIBS) +LIBS += -Wl,--whole-archive $(SPDK_WHOLE_LIBS) -Wl,--no-whole-archive + ifeq ($(CONFIG_RDMA),y) LIBS += -libverbs -lrdmacm endif @@ -70,7 +76,7 @@ LIBS += $(ENV_LINKER_ARGS) all : $(APP) -$(APP) : $(OBJS) $(SPDK_LIBS) $(BLOCKDEV_MODULES) $(LINKER_MODULES) $(ENV_LIBS) +$(APP) : $(OBJS) $(SPDK_LIBS) $(SPDK_WHOLE_LIBS) $(BLOCKDEV_MODULES) $(LINKER_MODULES) $(ENV_LIBS) $(LINK_C) clean :