build: add ENV_LINKER_ARGS to LINK_C and LINK_CXX

This allows us to remove $(ENV_LINKER_ARGS) from all of the
application Makefiles.

Modify spdk.unittest.mk to explicitly set ENV_LINKER_ARGS
to nothing, to avoid DPDK libraries from getting linked
into unit tests.  This seems better than creating separate
LINK_C rules for unit tests.  Provide a UNIT_TEST_LINK_ENV
flag to allow select unit tests to override this behavior -
it's needed for some of the env unit tests.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I647f2c848cf434023cf5a1f3a45869bbc4fc8102
Reviewed-on: https://review.gerrithub.io/434145
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Jim Harris 2018-11-20 09:59:47 -07:00 committed by Darek Stojaczyk
parent 80bfabcfcf
commit 3da5847023
28 changed files with 29 additions and 28 deletions

View File

@ -56,7 +56,6 @@ LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \
$(COPY_MODULES_LINKER_ARGS) \ $(COPY_MODULES_LINKER_ARGS) \
$(SOCK_MODULES_LINKER_ARGS) $(SOCK_MODULES_LINKER_ARGS)
LIBS += $(SPDK_LIB_LINKER_ARGS) LIBS += $(SPDK_LIB_LINKER_ARGS)
LIBS += $(ENV_LINKER_ARGS)
all : $(APP) all : $(APP)
@: @:

View File

@ -51,7 +51,7 @@ endif
LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \ LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \
$(COPY_MODULES_LINKER_ARGS) \ $(COPY_MODULES_LINKER_ARGS) \
$(SOCK_MODULES_LINKER_ARGS) \ $(SOCK_MODULES_LINKER_ARGS) \
$(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) $(SPDK_LIB_LINKER_ARGS)
all : $(APP) all : $(APP)
@: @:

View File

@ -59,7 +59,7 @@ endif
LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \ LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \
$(COPY_MODULES_LINKER_ARGS) \ $(COPY_MODULES_LINKER_ARGS) \
$(SOCK_MODULES_LINKER_ARGS) \ $(SOCK_MODULES_LINKER_ARGS) \
$(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) $(SPDK_LIB_LINKER_ARGS)
all: $(APP) all: $(APP)
@: @:

View File

@ -50,7 +50,6 @@ LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \
$(COPY_MODULES_LINKER_ARGS) \ $(COPY_MODULES_LINKER_ARGS) \
$(SOCK_MODULES_LINKER_ARGS) $(SOCK_MODULES_LINKER_ARGS)
LIBS += $(SPDK_LIB_LINKER_ARGS) LIBS += $(SPDK_LIB_LINKER_ARGS)
LIBS += $(ENV_LINKER_ARGS)
all : $(APP) all : $(APP)
@: @:

View File

@ -46,7 +46,7 @@ LDFLAGS += -shared -rdynamic
SPDK_LIB_LIST += thread util bdev conf copy rpc jsonrpc json log sock trace SPDK_LIB_LIST += thread util bdev conf copy rpc jsonrpc json log sock trace
LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) $(SOCK_MODULES_LINKER_ARGS) LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) $(SOCK_MODULES_LINKER_ARGS)
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) LIBS += $(SPDK_LIB_LINKER_ARGS)
all: $(APP) all: $(APP)
@: @:

View File

@ -42,7 +42,7 @@ SPDK_LIB_LIST = event_bdev event_copy
SPDK_LIB_LIST += bdev copy event thread util conf trace log jsonrpc json rpc sock SPDK_LIB_LIST += bdev copy event thread util conf trace log jsonrpc json rpc sock
LIBS += $(COPY_MODULES_LINKER_ARGS) $(BLOCKDEV_MODULES_LINKER_ARGS) $(SOCK_MODULES_LINKER_ARGS) LIBS += $(COPY_MODULES_LINKER_ARGS) $(BLOCKDEV_MODULES_LINKER_ARGS) $(SOCK_MODULES_LINKER_ARGS)
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) LIBS += $(SPDK_LIB_LINKER_ARGS)
all : $(APP) all : $(APP)
@: @:

View File

@ -46,7 +46,7 @@ SPDK_LIB_LIST += bdev copy event thread util conf trace \
BLOCKDEV_MODULES_LIST := $(filter-out bdev_lvol,$(BLOCKDEV_MODULES_LIST)) BLOCKDEV_MODULES_LIST := $(filter-out bdev_lvol,$(BLOCKDEV_MODULES_LIST))
LIBS += $(COPY_MODULES_LINKER_ARGS) $(BLOCKDEV_MODULES_LINKER_ARGS) $(SOCK_MODULES_LINKER_ARGS) LIBS += $(COPY_MODULES_LINKER_ARGS) $(BLOCKDEV_MODULES_LINKER_ARGS) $(SOCK_MODULES_LINKER_ARGS)
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) LIBS += $(SPDK_LIB_LINKER_ARGS)
all : $(APP) all : $(APP)
@: @:

View File

@ -43,7 +43,7 @@ SPDK_LIB_LIST += bdev copy event thread util conf trace \
log jsonrpc json rpc sock log jsonrpc json rpc sock
LIBS += $(COPY_MODULES_LINKER_ARGS) $(BLOCKDEV_MODULES_LINKER_ARGS) $(SOCK_MODULES_LINKER_ARGS) LIBS += $(COPY_MODULES_LINKER_ARGS) $(BLOCKDEV_MODULES_LINKER_ARGS) $(SOCK_MODULES_LINKER_ARGS)
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) LIBS += $(SPDK_LIB_LINKER_ARGS)
all : $(APP) all : $(APP)
@: @:

View File

@ -41,7 +41,7 @@ C_SRCS := perf.c
SPDK_LIB_LIST = ioat thread util log SPDK_LIB_LIST = ioat thread util log
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) LIBS += $(SPDK_LIB_LINKER_ARGS)
all: $(APP) all: $(APP)
@: @:

View File

@ -41,7 +41,7 @@ C_SRCS := verify.c
SPDK_LIB_LIST = ioat thread util log SPDK_LIB_LIST = ioat thread util log
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) LIBS += $(SPDK_LIB_LINKER_ARGS)
all: $(APP) all: $(APP)
@: @:

View File

@ -40,7 +40,7 @@ C_SRCS := hello_sock.c
SPDK_LIB_LIST += event thread util conf trace log jsonrpc json rpc sock SPDK_LIB_LIST += event thread util conf trace log jsonrpc json rpc sock
LIBS += $(SOCK_MODULES_LINKER_ARGS) $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) LIBS += $(SOCK_MODULES_LINKER_ARGS) $(SPDK_LIB_LINKER_ARGS)
all : $(APP) all : $(APP)
@: @:

View File

@ -42,7 +42,7 @@ C_SRCS = $(APP:%=%.c)
SPDK_LIB_LIST = nvme thread util log sock SPDK_LIB_LIST = nvme thread util log sock
LIBS += $(SOCK_MODULES_LINKER_ARGS) LIBS += $(SOCK_MODULES_LINKER_ARGS)
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) LIBS += $(SPDK_LIB_LINKER_ARGS)
ifeq ($(CONFIG_RDMA),y) ifeq ($(CONFIG_RDMA),y)
SYS_LIBS += -libverbs -lrdmacm SYS_LIBS += -libverbs -lrdmacm

View File

@ -219,11 +219,11 @@ COMPILE_CXX=\
# Link $(OBJS) and $(LIBS) into $@ (app) # Link $(OBJS) and $(LIBS) into $@ (app)
LINK_C=\ LINK_C=\
$(Q)echo " LINK $S/$@"; \ $(Q)echo " LINK $S/$@"; \
$(CC) -o $@ $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) $(SYS_LIBS) $(CC) -o $@ $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) $(ENV_LINKER_ARGS) $(SYS_LIBS)
LINK_CXX=\ LINK_CXX=\
$(Q)echo " LINK $S/$@"; \ $(Q)echo " LINK $S/$@"; \
$(CXX) -o $@ $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) $(SYS_LIBS) $(CXX) -o $@ $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) $(ENV_LINKER_ARGS) $(SYS_LIBS)
# #
# Variables to use for versioning shared libs # Variables to use for versioning shared libs

View File

@ -46,6 +46,10 @@ LIBS += -lcunit $(SPDK_STATIC_LIB_LINKER_ARGS)
APP = $(TEST_FILE:.c=) APP = $(TEST_FILE:.c=)
ifneq ($(UNIT_TEST_LINK_ENV),1)
ENV_LINKER_ARGS =
endif
all: $(APP) all: $(APP)
@: @:

View File

@ -51,7 +51,7 @@ endif
LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \ LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \
$(COPY_MODULES_LINKER_ARGS) \ $(COPY_MODULES_LINKER_ARGS) \
$(SOCK_MODULES_LINKER_ARGS) \ $(SOCK_MODULES_LINKER_ARGS) \
$(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) $(SPDK_LIB_LINKER_ARGS)
all : $(APP) all : $(APP)
@: @:

View File

@ -41,7 +41,7 @@ C_SRCS = histogram_perf.c
SPDK_LIB_LIST = thread util log SPDK_LIB_LIST = thread util log
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) LIBS += $(SPDK_LIB_LINKER_ARGS)
all: $(APP) all: $(APP)
@: @:

View File

@ -41,7 +41,7 @@ C_SRCS = jsoncat.c
SPDK_LIB_LIST = json thread util log SPDK_LIB_LIST = json thread util log
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) LIBS += $(SPDK_LIB_LINKER_ARGS)
all: $(APP) all: $(APP)
@: @:

View File

@ -44,7 +44,6 @@ SPDK_LIB_LIST = event conf nvme log trace rpc jsonrpc json thread util sock
LIBS += $(SOCK_MODULES_LINKER_ARGS) LIBS += $(SOCK_MODULES_LINKER_ARGS)
LIBS += $(SPDK_LIB_LINKER_ARGS) LIBS += $(SPDK_LIB_LINKER_ARGS)
LIBS += $(ENV_LINKER_ARGS)
all : $(APP) all : $(APP)
@: @:

View File

@ -47,7 +47,7 @@ LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \
$(COPY_MODULES_LINKER_ARGS) \ $(COPY_MODULES_LINKER_ARGS) \
$(SOCK_MODULES_LINKER_ARGS) $(SOCK_MODULES_LINKER_ARGS)
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) -lcunit LIBS += $(SPDK_LIB_LINKER_ARGS) -lcunit
all : $(APP) all : $(APP)
@: @:

View File

@ -47,7 +47,7 @@ LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \
$(COPY_MODULES_LINKER_ARGS) \ $(COPY_MODULES_LINKER_ARGS) \
$(SOCK_MODULES_LINKER_ARGS) $(SOCK_MODULES_LINKER_ARGS)
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) LIBS += $(SPDK_LIB_LINKER_ARGS)
all : $(APP) all : $(APP)
@: @:

View File

@ -45,7 +45,7 @@ SPDK_LIB_LIST += bdev copy event thread util conf trace \
log jsonrpc json rpc sock log jsonrpc json rpc sock
LIBS += $(COPY_MODULES_LINKER_ARGS) $(BLOCKDEV_MODULES_LINKER_ARGS) LIBS += $(COPY_MODULES_LINKER_ARGS) $(BLOCKDEV_MODULES_LINKER_ARGS)
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) LIBS += $(SPDK_LIB_LINKER_ARGS)
LIBS+= -L/usr/local/lib -lfuse3 LIBS+= -L/usr/local/lib -lfuse3
all : $(APP) all : $(APP)

View File

@ -45,7 +45,7 @@ SPDK_LIB_LIST += bdev copy event thread util conf trace \
log jsonrpc json rpc sock log jsonrpc json rpc sock
LIBS += $(COPY_MODULES_LINKER_ARGS) $(BLOCKDEV_MODULES_LINKER_ARGS) $(SOCK_MODULES_LINKER_ARGS) LIBS += $(COPY_MODULES_LINKER_ARGS) $(BLOCKDEV_MODULES_LINKER_ARGS) $(SOCK_MODULES_LINKER_ARGS)
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) LIBS += $(SPDK_LIB_LINKER_ARGS)
all : $(APP) all : $(APP)
@: @:

View File

@ -35,8 +35,8 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk include $(SPDK_ROOT_DIR)/mk/spdk.app.mk
UNIT_TEST_LINK_ENV = 1
CFLAGS += $(ENV_CFLAGS) CFLAGS += $(ENV_CFLAGS)
LIBS += $(ENV_LINKER_ARGS)
TEST_FILE = pci_ut.c TEST_FILE = pci_ut.c
ADDITIONAL_LIBS += $(ENV_LIBS) ADDITIONAL_LIBS += $(ENV_LIBS)

View File

@ -35,7 +35,7 @@ SPDK_ROOT_DIR := $(abspath $(CURDIR)/../../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk include $(SPDK_ROOT_DIR)/mk/spdk.app.mk
LIBS += $(ENV_LINKER_ARGS) UNIT_TEST_LINK_ENV = 1
TEST_FILE = vtophys.c TEST_FILE = vtophys.c
ADDITIONAL_LIBS += $(ENV_LIBS) ADDITIONAL_LIBS += $(ENV_LIBS)

View File

@ -40,7 +40,7 @@ C_SRCS := event_perf.c
SPDK_LIB_LIST = event trace conf thread util log rpc jsonrpc json sock SPDK_LIB_LIST = event trace conf thread util log rpc jsonrpc json sock
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) LIBS += $(SPDK_LIB_LINKER_ARGS)
all : $(APP) all : $(APP)
@: @:

View File

@ -40,7 +40,7 @@ C_SRCS := reactor.c
SPDK_LIB_LIST = event trace conf thread util log rpc jsonrpc json sock SPDK_LIB_LIST = event trace conf thread util log rpc jsonrpc json sock
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) LIBS += $(SPDK_LIB_LINKER_ARGS)
all : $(APP) all : $(APP)
@: @:

View File

@ -40,7 +40,7 @@ C_SRCS := reactor_perf.c
SPDK_LIB_LIST = event trace conf thread util log rpc jsonrpc json sock SPDK_LIB_LIST = event trace conf thread util log rpc jsonrpc json sock
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) LIBS += $(SPDK_LIB_LINKER_ARGS)
all : $(APP) all : $(APP)
@: @:

View File

@ -42,7 +42,7 @@ C_SRCS := rpc_client_test.c
SPDK_LIB_LIST = jsonrpc json rpc log util SPDK_LIB_LIST = jsonrpc json rpc log util
LIBS += $(SPDK_LIB_LINKER_ARGS) $(ENV_LINKER_ARGS) LIBS += $(SPDK_LIB_LINKER_ARGS)
all : $(APP) all : $(APP)
@: @: