build: use DEPDIRS variables to build SPDK_LIB_LIST

All of our Makefiles duplicate huge lists of libraries
in SPDK_LIB_LIST.  We have a very precise and accurate
accounting of the library dependencies in
mk/spdk.lib_deps.mk which can be used to generate
the full list if the app specifies the modules and
subsystem libraries it wishes to link.

I did a first pass through all of the existing
Makefiles to take advantage of this new functionality.
There may be more optimizations we can make later but
don't want to hold up this patch for all of them.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Icdaf6f749a6908df2c2ce2db22631a4af4ff3a9e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5553
Community-CI: Broadcom CI
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Jim Harris 2020-12-11 20:41:37 +00:00 committed by Tomasz Zawadzki
parent 27c2daff1d
commit d132ee3531
36 changed files with 70 additions and 133 deletions

View File

@ -43,17 +43,14 @@ CFLAGS += -I$(SPDK_ROOT_DIR)/lib
C_SRCS := iscsi_tgt.c
SPDK_LIB_LIST = $(ALL_MODULES_LIST)
SPDK_LIB_LIST += $(EVENT_BDEV_SUBSYSTEM) event_iscsi event_net event_scsi event
SPDK_LIB_LIST += jsonrpc json rpc bdev iscsi scsi accel trace conf
SPDK_LIB_LIST += thread util log net sock notify
SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_iscsi event_net
ifeq ($(SPDK_ROOT_DIR)/lib/env_dpdk,$(CONFIG_ENV))
SPDK_LIB_LIST += env_dpdk_rpc
endif
ifeq ($(OS),Linux)
SPDK_LIB_LIST += event_nbd nbd
SPDK_LIB_LIST += event_nbd
endif
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -37,7 +37,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.modules.mk
APP = iscsi_top
SPDK_LIB_LIST = jsonrpc json rpc log util
SPDK_LIB_LIST = rpc
CFLAGS += -I$(SPDK_ROOT_DIR)/lib

View File

@ -39,17 +39,14 @@ APP = nvmf_tgt
C_SRCS := nvmf_main.c
SPDK_LIB_LIST = $(ALL_MODULES_LIST)
SPDK_LIB_LIST += $(EVENT_BDEV_SUBSYSTEM) event_nvmf event_net
SPDK_LIB_LIST += nvmf event log trace conf thread util bdev accel rpc jsonrpc json net sock
SPDK_LIB_LIST += notify
SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_nvmf
ifeq ($(SPDK_ROOT_DIR)/lib/env_dpdk,$(CONFIG_ENV))
SPDK_LIB_LIST += env_dpdk_rpc
endif
ifeq ($(OS),Linux)
SPDK_LIB_LIST += event_nbd nbd
SPDK_LIB_LIST += event_nbd
endif
ifeq ($(CONFIG_FC),y)

View File

@ -39,9 +39,6 @@ APP = spdk_dd
C_SRCS := spdk_dd.c
SPDK_LIB_LIST = $(ALL_MODULES_LIST)
SPDK_LIB_LIST += event_sock event_bdev event_accel event_vmd
SPDK_LIB_LIST += bdev accel event thread util conf trace \
log jsonrpc json rpc sock notify
SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -38,14 +38,6 @@ APP = spdk_lspci
C_SRCS := spdk_lspci.c
SPDK_LIB_LIST = $(SOCK_MODULES_LIST)
SPDK_LIB_LIST += nvme thread util log sock vmd jsonrpc json rpc
ifeq ($(CONFIG_RDMA),y)
SPDK_LIB_LIST += rdma
ifeq ($(CONFIG_RDMA_PROV),mlx5_dv)
SYS_LIBS += -lmlx5
endif
endif
SPDK_LIB_LIST = $(SOCK_MODULES_LIST) nvme vmd
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -41,22 +41,17 @@ C_SRCS := spdk_tgt.c
SPDK_LIB_LIST = $(ALL_MODULES_LIST)
ifeq ($(OS),Linux)
ifeq ($(CONFIG_VHOST),y)
SPDK_LIB_LIST += vhost event_vhost
endif
endif
SPDK_LIB_LIST += $(EVENT_BDEV_SUBSYSTEM) event_iscsi event_net event_scsi event_nvmf event
SPDK_LIB_LIST += nvmf trace log conf thread util bdev iscsi scsi accel rpc jsonrpc json
SPDK_LIB_LIST += net sock notify
SPDK_LIB_LIST += event_iscsi event_nvmf
ifeq ($(SPDK_ROOT_DIR)/lib/env_dpdk,$(CONFIG_ENV))
SPDK_LIB_LIST += env_dpdk_rpc
endif
ifeq ($(OS),Linux)
SPDK_LIB_LIST += event_nbd nbd
SPDK_LIB_LIST += event_nbd
ifeq ($(CONFIG_VHOST),y)
SPDK_LIB_LIST += event_vhost
endif
endif
ifeq ($(CONFIG_FC),y)

View File

@ -38,7 +38,7 @@ APP = spdk_top
C_SRCS := spdk_top.c
SPDK_LIB_LIST = jsonrpc json rpc log util
SPDK_LIB_LIST = rpc
LIBS=-lncurses -lpanel -lmenu
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -39,13 +39,7 @@ APP = vhost
C_SRCS := vhost.c
SPDK_LIB_LIST = $(ALL_MODULES_LIST)
SPDK_LIB_LIST += vhost event_vhost
SPDK_LIB_LIST += $(EVENT_BDEV_SUBSYSTEM) event_net event_scsi event
SPDK_LIB_LIST += jsonrpc json rpc bdev scsi accel trace conf
SPDK_LIB_LIST += thread util log
SPDK_LIB_LIST += event_nbd nbd net sock notify
SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_vhost event_nbd
ifeq ($(SPDK_ROOT_DIR)/lib/env_dpdk,$(CONFIG_ENV))
SPDK_LIB_LIST += env_dpdk_rpc

View File

@ -39,9 +39,6 @@ APP = accel_perf
C_SRCS := accel_perf.c
SPDK_LIB_LIST = $(ALL_MODULES_LIST)
SPDK_LIB_LIST += $(EVENT_BDEV_SUBSYSTEM)
SPDK_LIB_LIST += bdev accel event thread util conf trace \
log jsonrpc json rpc sock notify
SPDK_LIB_LIST = $(ACCEL_MODULES_LIST) event_accel
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -40,8 +40,6 @@ FIO_PLUGIN := spdk_bdev
C_SRCS = fio_plugin.c
SPDK_LIB_LIST = $(ALL_MODULES_LIST)
SPDK_LIB_LIST += thread util bdev conf accel rpc jsonrpc json log sock trace notify
SPDK_LIB_LIST += event $(EVENT_BDEV_SUBSYSTEM)
SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev
include $(SPDK_ROOT_DIR)/mk/spdk.fio.mk

View File

@ -37,8 +37,6 @@ APP = hello_bdev
C_SRCS := hello_bdev.c
SPDK_LIB_LIST = $(ALL_MODULES_LIST)
SPDK_LIB_LIST += $(EVENT_BDEV_SUBSYSTEM)
SPDK_LIB_LIST += bdev accel event thread util conf trace log jsonrpc json rpc sock notify
SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -38,9 +38,6 @@ APP = blobcli
C_SRCS := blobcli.c
# Don't link bdev_lvol in blobcli - otherwise this utility cannot operate on an lvolstore
SPDK_LIB_LIST = $(filter-out bdev_lvol,$(ALL_MODULES_LIST))
SPDK_LIB_LIST += $(EVENT_BDEV_SUBSYSTEM)
SPDK_LIB_LIST += bdev accel event thread util conf trace \
log jsonrpc json rpc sock notify
SPDK_LIB_LIST = $(filter-out bdev_lvol,$(ALL_MODULES_LIST)) event_bdev
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -37,9 +37,6 @@ APP = hello_blob
C_SRCS := hello_blob.c
SPDK_LIB_LIST = $(ALL_MODULES_LIST)
SPDK_LIB_LIST += $(EVENT_BDEV_SUBSYSTEM)
SPDK_LIB_LIST += bdev accel event thread util conf trace \
log jsonrpc json rpc sock notify
SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -40,15 +40,13 @@ APP = interrupt_tgt
C_SRCS := interrupt_tgt.c
# Basic libaries to support spdk application
SPDK_LIB_LIST += event thread
SPDK_LIB_LIST += jsonrpc json rpc trace conf util log
SPDK_LIB_LIST += event
# Basic bdev libraries
SPDK_LIB_LIST += bdev notify accel vmd sock
SPDK_LIB_LIST += $(EVENT_BDEV_SUBSYSTEM) # event_bdev depends on some other event modules, but they dont support edriven yet
SPDK_LIB_LIST += event_bdev
# Aio bdev library
SPDK_LIB_LIST += bdev_aio
# NBD libraries
SPDK_LIB_LIST += nbd event_nbd
SPDK_LIB_LIST += event_nbd
# some bdev modules don't have pollers, so they can be directly runnning in edriven mode
SPDK_LIB_LIST += bdev_malloc bdev_passthru bdev_error bdev_gpt bdev_split bdev_raid
# logical volume and blobstore can directly run in edriven mode
@ -56,8 +54,8 @@ SPDK_LIB_LIST += bdev_lvol lvol blob_bdev blob
# blobfs libraries
SPDK_LIB_LIST += blobfs blobfs_bdev
# vhost blk related libraries.
SPDK_LIB_LIST += vhost event_vhost
SPDK_LIB_LIST += scsi event_scsi # vhost-scsi is not supported, just because vhost lib requires scsi related libs
SPDK_LIB_LIST += event_vhost
SPDK_LIB_LIST += event_scsi # vhost-scsi is not supported, just because vhost lib requires scsi related libs
ifeq ($(SPDK_ROOT_DIR)/lib/env_dpdk,$(CONFIG_ENV))
SPDK_LIB_LIST += env_dpdk_rpc

View File

@ -38,6 +38,6 @@ APP = ioat_perf
C_SRCS := perf.c
SPDK_LIB_LIST = ioat thread util log
SPDK_LIB_LIST = ioat util
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -38,6 +38,6 @@ APP = verify
C_SRCS := verify.c
SPDK_LIB_LIST = ioat thread util log
SPDK_LIB_LIST = ioat util
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -40,11 +40,6 @@ FIO_PLUGIN := spdk_nvme
C_SRCS = fio_plugin.c
SPDK_LIB_LIST = $(SOCK_MODULES_LIST)
SPDK_LIB_LIST += nvme thread util log sock vmd jsonrpc json rpc
ifeq ($(CONFIG_RDMA),y)
SPDK_LIB_LIST += rdma
endif
SPDK_LIB_LIST = $(SOCK_MODULES_LIST) nvme vmd
include $(SPDK_ROOT_DIR)/mk/spdk.fio.mk

View File

@ -38,9 +38,7 @@ include $(SPDK_ROOT_DIR)/mk/spdk.modules.mk
APP := nvmf
C_SRCS := nvmf.c
SPDK_LIB_LIST = $(ALL_MODULES_LIST)
SPDK_LIB_LIST += nvmf thread util bdev conf accel rpc jsonrpc json log sock trace notify
SPDK_LIB_LIST += event $(EVENT_BDEV_SUBSYSTEM)
SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev nvmf
ifeq ($(CONFIG_FC),y)
ifneq ($(strip $(CONFIG_FC_PATH)),)

View File

@ -38,6 +38,6 @@ APP = hello_sock
C_SRCS := hello_sock.c
SPDK_LIB_LIST = $(SOCK_MODULES_LIST)
SPDK_LIB_LIST += event_net net event thread util conf trace log jsonrpc json rpc sock notify
SPDK_LIB_LIST += event_net sock
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -53,9 +53,7 @@ ifeq ($(CONFIG_ASAN),y)
CXXFLAGS += -fno-sanitize=address
endif
SPDK_LIB_LIST = $(ALL_MODULES_LIST)
SPDK_LIB_LIST += $(EVENT_BDEV_SUBSYSTEM)
SPDK_LIB_LIST += bdev accel event util conf trace log jsonrpc json rpc sock thread notify
SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev
AM_LINK += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS)
AM_LINK += $(SYS_LIBS)

View File

@ -38,11 +38,6 @@ include $(SPDK_ROOT_DIR)/mk/spdk.modules.mk
C_SRCS := $(APP:%=%.c)
SPDK_LIB_LIST = $(SOCK_MODULES_LIST)
SPDK_LIB_LIST += nvme thread util log sock vmd jsonrpc json rpc
ifeq ($(CONFIG_RDMA),y)
SPDK_LIB_LIST += rdma
endif
SPDK_LIB_LIST = $(SOCK_MODULES_LIST) nvme vmd
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -31,12 +31,33 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
SPDK_LIB_FILES = $(call spdk_lib_list_to_static_libs,$(SPDK_LIB_LIST))
include $(SPDK_ROOT_DIR)/mk/spdk.lib_deps.mk
# _uniq returns the unique elements from the list specified. It does
# not change the order of the elements. If the same element occurs
# multiple times in the list, the last instance is kept and the others
# removed.
# Example: _uniq(conf log json log util util log util) = conf json log util
define _uniq
$(if $1,$(call _uniq,$(filter-out $(lastword $1),$1)) $(lastword $1))
endef
define _deplibs
$(if $1,$(foreach d,$1,$(d) $(call _deplibs,$(DEPDIRS-$(d)))))
endef
define deplibs
$(call _uniq,$(call _deplibs,$1))
endef
SPDK_DEPLIB_LIST += $(call deplibs,$(SPDK_LIB_LIST))
SPDK_LIB_FILES = $(call spdk_lib_list_to_static_libs,$(SPDK_DEPLIB_LIST))
SPDK_LIB_LINKER_ARGS = \
-L$(SPDK_ROOT_DIR)/build/lib \
-Wl,--whole-archive \
-Wl,--no-as-needed \
$(SPDK_LIB_LIST:%=-lspdk_%) \
$(SPDK_DEPLIB_LIST:%=-lspdk_%) \
-Wl,--no-whole-archive
# This is primarily used for unit tests to ensure they link when shared library

View File

@ -39,13 +39,10 @@ APP = bdev_svc
C_SRCS := bdev_svc.c
SPDK_LIB_LIST = $(ALL_MODULES_LIST)
SPDK_LIB_LIST += $(EVENT_BDEV_SUBSYSTEM)
SPDK_LIB_LIST += nvmf event log trace conf thread util bdev accel rpc jsonrpc json sock
SPDK_LIB_LIST += notify
SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev
ifeq ($(OS),Linux)
SPDK_LIB_LIST += event_nbd nbd
SPDK_LIB_LIST += event_nbd
endif
ifeq ($(CONFIG_FC),y)

View File

@ -45,7 +45,6 @@ ISCSI_OBJS = md5 param conn tgt_node init_grp portal_grp
LIBS += $(SCSI_OBJS:%=$(SPDK_ROOT_DIR)/lib/scsi/%.o)
LIBS += $(ISCSI_OBJS:%=$(SPDK_ROOT_DIR)/lib/iscsi/%.o)
SPDK_LIB_LIST += $(SOCK_MODULES_LIST)
SPDK_LIB_LIST += conf event json jsonrpc log scsi bdev notify rpc sock thread trace util
SPDK_LIB_LIST += $(SOCK_MODULES_LIST) event scsi
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -39,11 +39,6 @@ CFLAGS += -I$(SPDK_ROOT_DIR)/test/app/fuzz/common
C_SRCS := nvme_fuzz.c
SPDK_LIB_LIST += $(SOCK_MODULES_LIST)
SPDK_LIB_LIST += conf event json jsonrpc log nvme rpc sock thread trace util
ifeq ($(CONFIG_RDMA),y)
SPDK_LIB_LIST += rdma
endif
SPDK_LIB_LIST += $(SOCK_MODULES_LIST) event nvme conf
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -38,5 +38,5 @@ CFLAGS += -I$(SPDK_ROOT_DIR)/test/app/fuzz/common
C_SRCS := vhost_fuzz_rpc.c vhost_fuzz.c
SPDK_LIB_LIST += event conf json jsonrpc rpc util log sock trace thread virtio
SPDK_LIB_LIST += event conf rpc sock virtio
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -39,11 +39,6 @@ APP = stub
C_SRCS := stub.c
SPDK_LIB_LIST = $(SOCK_MODULES_LIST)
SPDK_LIB_LIST += event conf nvme log trace rpc jsonrpc json thread util sock notify
ifeq ($(CONFIG_RDMA),y)
SPDK_LIB_LIST += rdma
endif
SPDK_LIB_LIST = $(SOCK_MODULES_LIST) event nvme
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -39,9 +39,7 @@ APP = bdevio
C_SRCS := bdevio.c
SPDK_LIB_LIST = $(ALL_MODULES_LIST)
SPDK_LIB_LIST += $(EVENT_BDEV_SUBSYSTEM)
SPDK_LIB_LIST += bdev accel event trace log conf thread util rpc jsonrpc json sock notify
SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev
LIBS += -lcunit

View File

@ -39,13 +39,10 @@ APP = bdevperf
C_SRCS := bdevperf.c
SPDK_LIB_LIST = $(ALL_MODULES_LIST)
SPDK_LIB_LIST += $(EVENT_BDEV_SUBSYSTEM)
SPDK_LIB_LIST += bdev accel event trace log conf thread util sock notify
SPDK_LIB_LIST += rpc jsonrpc json
SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev conf
ifeq ($(OS),Linux)
SPDK_LIB_LIST += event_nbd nbd
SPDK_LIB_LIST += event_nbd
endif
ifeq ($(SPDK_ROOT_DIR)/lib/env_dpdk,$(CONFIG_ENV))

View File

@ -39,9 +39,6 @@ APP = fuse
C_SRCS := fuse.c
SPDK_LIB_LIST = $(ALL_MODULES_LIST)
SPDK_LIB_LIST += $(EVENT_BDEV_SUBSYSTEM)
SPDK_LIB_LIST += bdev accel event thread util conf trace \
log jsonrpc json rpc sock notify
SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -39,9 +39,6 @@ APP = mkfs
C_SRCS := mkfs.c
SPDK_LIB_LIST = $(ALL_MODULES_LIST)
SPDK_LIB_LIST += $(EVENT_BDEV_SUBSYSTEM)
SPDK_LIB_LIST += bdev accel event thread util conf trace \
log jsonrpc json rpc sock notify
SPDK_LIB_LIST = $(ALL_MODULES_LIST) event_bdev
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -41,9 +41,7 @@ C_SRCS := app_repeat.c
# Some of the modules and libaries are not repeatable yet, only organize
# the repeatable ones.
SPDK_LIB_LIST = event_bdev event_accel event_vmd event_sock
SPDK_LIB_LIST += event log trace conf thread util bdev accel rpc jsonrpc json sock vmd
SPDK_LIB_LIST += notify
SPDK_LIB_LIST += event_nbd nbd
SPDK_LIB_LIST += event_nbd
BLOCKDEV_LIST = bdev_malloc bdev_null
BLOCKDEV_LIST += bdev_aio

View File

@ -37,6 +37,6 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
APP = event_perf
C_SRCS := event_perf.c
SPDK_LIB_LIST = event trace conf thread util log rpc jsonrpc json sock notify
SPDK_LIB_LIST = event
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -37,6 +37,6 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
APP = reactor
C_SRCS := reactor.c
SPDK_LIB_LIST = event trace conf thread util log rpc jsonrpc json sock notify
SPDK_LIB_LIST = event
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -37,6 +37,6 @@ include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
APP = reactor_perf
C_SRCS := reactor_perf.c
SPDK_LIB_LIST = event trace conf thread util log rpc jsonrpc json sock notify
SPDK_LIB_LIST = event
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk

View File

@ -39,6 +39,6 @@ APP = rpc_client_test
C_SRCS := rpc_client_test.c
SPDK_LIB_LIST = jsonrpc json rpc log util
SPDK_LIB_LIST = rpc
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk