configure: Checking if libbsd is used by DPDK

- DPDK may or may not decide to use libbsd. SPDK needs to find this out
  and add -lbsd to the list of libraries to prevent linking issues in
  case that --with-dpdk=dpdk/install option is used.
- Use pkg-config for proper detection if the libbsd is in use.

Signed-off-by: Yuriy Umanets <yumanets@nvidia.com>
Change-Id: Ie3de0363fefb9b7337394b00adc862839834f164
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11616
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Yuriy Umanets 2022-01-18 09:57:15 +02:00 committed by Tomasz Zawadzki
parent 7b04eb72d2
commit 3e3fbf919f
4 changed files with 24 additions and 1 deletions

3
CONFIG
View File

@ -195,3 +195,6 @@ CONFIG_USDT=n
# Build with IDXD kernel support.
# In this mode, SPDK shares the DSA device with the kernel.
CONFIG_IDXD_KERNEL=n
# Is DPDK using libbsd?
CONFIG_HAVE_LIBBSD=n

14
configure vendored
View File

@ -319,6 +319,9 @@ for i in "$@"; do
CONFIG[DPDK_LIB_DIR]=$dpdk_libdir
CONFIG[DPDK_INC_DIR]=$dpdk_incdir
CONFIG[DPDK_PKG_CONFIG]=y
if pkg-config --print-requires libdpdk | grep "libbsd" > /dev/null 2>&1; then
CONFIG[HAVE_LIBBSD]=y
fi
CFLAGS="${CFLAGS:+$CFLAGS }$(pkg-config --cflags libdpdk)"
else
echo "libdpdk.pc not found, aborting"
@ -341,9 +344,18 @@ for i in "$@"; do
echo "ERROR: do you have another DPDK installed in the system?"
exit 1
fi
dpdk_reqs=$(PKG_CONFIG_PATH="$dpdk_libdir/pkgconfig" pkg-config --print-requires libdpdk)
if echo $dpdk_reqs | grep "libbsd" > /dev/null 2>&1; then
CONFIG[HAVE_LIBBSD]=y
fi
CFLAGS="${CFLAGS:+$CFLAGS }$(PKG_CONFIG_PATH="$dpdk_libdir/pkgconfig" pkg-config --cflags libdpdk)"
dpdk_incdir=$(PKG_CONFIG_PATH="$dpdk_libdir/pkgconfig" pkg-config --variable=includedir libdpdk)
else
echo "Using $dpdk_incdir/rte_build_config.h for additional libs..."
if grep -F "define RTE_USE_LIBBSD 1" $dpdk_incdir/rte_build_config.h > /dev/null 2>&1; then
CONFIG[HAVE_LIBBSD]=y
fi
fi
echo "DPDK libraries: $dpdk_libdir"
echo "DPDK includes: $dpdk_incdir"

View File

@ -144,6 +144,10 @@ ifeq ($(CONFIG_IPSEC_MB),y)
DPDK_PRIVATE_LINKER_ARGS += -lIPSec_MB -L$(IPSEC_MB_DIR)
endif
ifeq ($(CONFIG_HAVE_LIBBSD),y)
DPDK_PRIVATE_LINKER_ARGS += -lbsd
endif
ifeq ($(CONFIG_REDUCE),y)
DPDK_PRIVATE_LINKER_ARGS += -lisal -L$(ISAL_DIR)/.libs
ifeq ($(CONFIG_REDUCE_MLX5),y)

View File

@ -73,6 +73,10 @@ override LDFLAGS += \
-Wl,--no-whole-archive \
-ldl -pthread -lrt -lrdmacm -lnuma -libverbs
ifeq ($(CONFIG_HAVE_LIBBSD),y)
override LDFLAGS += -lbsd
endif
ifeq ($(CONFIG_ISAL), y)
ISAL_DIR=$(SPDK_ROOT_DIR)/isa-l
override LDFLAGS += -L$(ISAL_DIR)/.libs -lisal