build: add combined shared library (libspdk.so)

Change-Id: If48df087c145a3fd278c0ae04558d8352b01cc1a
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/414687
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Daniel Verkamp 2018-06-11 12:40:29 -07:00 committed by Jim Harris
parent 9e21207a7c
commit 6f46e272c3
5 changed files with 123 additions and 3 deletions

View File

@ -2,6 +2,15 @@
## v18.07: (Upcoming Release)
### Build System
The build system now generates a combined shared library (libspdk.so) that may be used
in place of the individual static libraries (libspdk_*.a).
The combined library includes all components of SPDK and is intended to make linking
against SPDK easier.
The static libraries are also still provided for users that prefer to link only the
minimal set of components required.
### RPC
The `start_nbd_disk` RPC method now returns the path to the kernel NBD device node

View File

@ -36,7 +36,7 @@ S :=
SPDK_ROOT_DIR := $(CURDIR)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
DIRS-y += lib examples app include
DIRS-y += lib shared_lib examples app include
DIRS-$(CONFIG_TESTS) += test
.PHONY: all clean $(DIRS-y) config.h CONFIG.local mk/cc.mk cc_version cxx_version
@ -56,6 +56,7 @@ clean: $(DIRS-y)
install: all
$(Q)echo "Installed to $(DESTDIR)$(CONFIG_PREFIX)"
shared_lib: lib
lib: $(DPDKBUILD)
app: lib
test: lib

View File

@ -58,9 +58,7 @@ else
DPDK_CONFIG := $(DPDK_CONFIG)-gcc
endif
ifeq ($(CONFIG_FIO_PLUGIN),y)
DPDK_CFLAGS = -fPIC
endif
ifeq ($(CONFIG_DEBUG),y)
DPDK_CFLAGS += -O0 -g

View File

@ -238,6 +238,12 @@ INSTALL_LIB=\
install -d -m 755 "$(DESTDIR)$(libdir)"; \
install -m 644 "$(LIB)" "$(DESTDIR)$(libdir)/"
# Install a shared library
INSTALL_SHARED_LIB=\
$(Q)echo " INSTALL $(DESTDIR)$(libdir)/$(notdir $(SHARED_LIB))"; \
install -d -m 755 "$(DESTDIR)$(libdir)"; \
install -m 644 "$(SHARED_LIB)" "$(DESTDIR)$(libdir)/"
# Install an app binary
INSTALL_APP=\
$(Q)echo " INSTALL $(DESTDIR)$(bindir)/$(APP)"; \

106
shared_lib/Makefile Normal file
View File

@ -0,0 +1,106 @@
#
# BSD LICENSE
#
# Copyright (c) Intel Corporation.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Intel Corporation nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
SPDK_ROOT_DIR := $(abspath $(CURDIR)/..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk
include $(SPDK_ROOT_DIR)/mk/spdk.app.mk
include $(SPDK_ROOT_DIR)/mk/spdk.modules.mk
# Build combined libspdk.so shared library
SHARED_LIB = $(SPDK_ROOT_DIR)/build/lib/libspdk.so
SPDK_LIB_LIST += app_rpc
SPDK_LIB_LIST += bdev
SPDK_LIB_LIST += bdev_rpc
SPDK_LIB_LIST += blobfs
SPDK_LIB_LIST += conf
SPDK_LIB_LIST += copy
SPDK_LIB_LIST += event
SPDK_LIB_LIST += event_bdev
SPDK_LIB_LIST += event_copy
SPDK_LIB_LIST += event_iscsi
SPDK_LIB_LIST += event_net
SPDK_LIB_LIST += event_nvmf
SPDK_LIB_LIST += event_scsi
SPDK_LIB_LIST += iscsi
SPDK_LIB_LIST += json
SPDK_LIB_LIST += jsonrpc
SPDK_LIB_LIST += log
SPDK_LIB_LIST += log_rpc
SPDK_LIB_LIST += nvmf
SPDK_LIB_LIST += rpc
SPDK_LIB_LIST += scsi
SPDK_LIB_LIST += trace
SPDK_LIB_LIST += util
ifeq ($(OS),Linux)
SPDK_LIB_LIST += event_nbd
SPDK_LIB_LIST += nbd
ifeq ($(CONFIG_VHOST),y)
SPDK_LIB_LIST += event_vhost
SPDK_LIB_LIST += rte_vhost
SPDK_LIB_LIST += vhost
endif
endif
LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS)
LIBS += $(COPY_MODULES_LINKER_ARGS)
LIBS += $(NET_MODULES_LINKER_ARGS)
LIBS += $(SPDK_LIB_LINKER_ARGS)
LIBS += $(ENV_LINKER_ARGS)
comma := ,
$(SHARED_LIB): $(SPDK_LIB_FILES) $(SPDK_WHOLE_LIBS) $(BLOCKDEV_MODULES_FILES) $(COPY_MODULES_FILES) $(NET_MODULES_FILES) $(LINKER_MODULES) $(ENV_LIBS) $(MAKEFILE_LIST)
$(Q)echo " SO $(notdir $@)"; \
rm -f $@; \
$(CC) -o $@ -shared $(CPPFLAGS) $(LDFLAGS) \
-Wl,--whole-archive \
$(filter-out -Wl$(comma)--no-whole-archive,$(LIBS)) \
-Wl,--no-whole-archive \
-lcrypto \
$(SYS_LIBS)
.PHONY: all clean $(DIRS-y)
all: $(SHARED_LIB)
clean:
$(CLEAN_C) $(SHARED_LIB)
install:
$(INSTALL_SHARED_LIB)
include $(SPDK_ROOT_DIR)/mk/spdk.subdirs.mk