首页 > 解决方案 > 将外部 DPVS 应用程序(使用 Makefile)与使用 Meson 构建的 DPDK 链接

问题描述

DPVS 建议使用dpdk-stable-18.11.2使用 Makefile 进行构建。但是当前的 DPDK LTS 版本 18.11.11 支持 meson -ninja构建系统以及 Makefile 系统。

我一直在试验port to a more recent DPDK version只支持介子忍者而不是不推荐使用的 Makefile 系统的代码。我的问题DPVS 链接问题是在链接到使用 meson-ninja 构建的 DPDK 时,我无法解决依赖问题。当我尝试链接使用 Makefiles 构建的 DPDK 18.11 时,同样的工作没有问题。我正在使用 KVM-QEMU运行带有 NIC Virtio/E1000的来宾操作系统。来宾操作系统是Ubuntu 18.04 LTS (x64)

DPDK 库通过 dpdk.mk 由 DPVS 项目链接当前链接选项为:

LIBS += -Wl,--no-as-needed -fvisibility=default \
        -Wl,--whole-archive -lrte_pmd_vmxnet3_uio -lrte_pmd_i40e -lrte_pmd_ixgbe \
        -lrte_pmd_e1000 -lrte_pmd_bnxt -lrte_pmd_ring -lrte_pmd_bond -lrte_ethdev -lrte_ip_frag \
        -Wl,--whole-archive -lrte_hash -lrte_kvargs -Wl,-lrte_mbuf -lrte_eal \
        -Wl,-lrte_mempool -lrte_ring -lrte_cmdline -lrte_cfgfile -lrte_kni \
        -lrte_mempool_ring -lrte_timer -lrte_net -Wl,-lrte_pmd_virtio \
        -lrte_pci -lrte_bus_pci -lrte_bus_vdev -lrte_lpm -lrte_pdump \
        -Wl,--no-whole-archive -lrt -lm -ldl -lcrypto

到目前为止我已经尝试过:

因此,请帮助解决此链接问题(这似乎是与-Wl标志选项链接相关的一般问题)。

谢谢!:)


编辑:更新的错误日志

cc -D DPVS_MAX_SOCKET=1 -D DPVS_MAX_LCORE=3 -D CONFIG_DPVS_TRACING \
-D CONFIG_DPVS_NEIGH_DEBUG -D CONFIG_DPVS_IPVS_DEBUG -D DPVS_CFG_PARSER_DEBUG \
-D CONFIG_DPVS_IP_HEADER_DEBUG -D CONFIG_DPVS_PDUMP \
-D CONFIG_DPVS_IPSET_DEBUG -D CONFIG_MSG_DEBUG \
-include /home/anshul/loadbalancer/dpdk-stable-18.11.10/sdk/build/include/rte_config.h -march=native \
-DRTE_MACHINE_CPUFLAG_SSE -DRTE_MACHINE_CPUFLAG_SSE2 \
-DRTE_MACHINE_CPUFLAG_SSE3 -DRTE_MACHINE_CPUFLAG_SSSE3 \
-DRTE_MACHINE_CPUFLAG_SSE4_1 -DRTE_MACHINE_CPUFLAG_SSE4_2  \
-D __DPVS__ -DDPVS_VERSION=\"1.8-4\" \
-DDPVS_BUILD_DATE=\"2021.01.25.10:11:27\" \
-Werror -Wstrict-prototypes -Wmissing-prototypes \
-mcmodel=medium -fgnu89-inline -Wno-format-truncation \
-Wno-stringop-truncation -Wstringop-overflow=0 -g -O0 \
-D DEBUG -rdynamic \
-I /home/anshul/loadbalancer/dpdk-stable-18.11.10/sdk/build/include \
-I /home/anshul/loadbalancer/dpvs/src//../include \
-L /home/anshul/loadbalancer/dpdk-stable-18.11.10/sdk/build/lib \
-L /home/anshul/loadbalancer/dpdk-stable-18.11.10/sdk/build/lib/x86_64-linux-gnu/ \
-L /home/anshul/loadbalancer/dpdk-stable-18.11.10/sdk/build/lib/x86_64-linux-gnu/dpdk/pmds-18.11 \
-Wl,--no-as-needed -fvisibility=default \
-Wl,--whole-archive -lrte_pmd_vmxnet3 -lrte_pmd_i40e -lrte_pmd_ixgbe -lrte_pmd_e1000 -lrte_pmd_bnxt -lrte_pmd_ring -lrte_pmd_bond -lrte_ethdev -lrte_ip_frag \
-Wl,--whole-archive -lrte_hash -lrte_kvargs \
-Wl,-lrte_mbuf -lrte_eal \
-Wl,-lrte_mempool -lrte_ring -lrte_cmdline -lrte_cfgfile -lrte_kni -lrte_mempool_ring -lrte_timer -lrte_net \
-Wl,-lrte_pmd_virtio -lrte_pci -lrte_bus_pci -lrte_bus_vdev -lrte_lpm -lrte_pdump \
-Wl,--no-whole-archive -lrt -lm -ldl -lcrypto \
-Wl,-rpath,/home/anshul/loadbalancer/dpdk-stable-18.11.10/sdk/build/lib/x86_64-linux-gnu/ -lpthread -lnuma /home/anshul/loadbalancer/dpvs/src/cfgfile.o ... -o dpvs
/home/anshul/loadbalancer/dpvs/src/netif.o: In function `get_bond_status':
/home/anshul/loadbalancer/dpvs/src/netif.c:4738: undefined reference to `rte_eth_bond_link_monitoring_get'
/home/anshul/loadbalancer/dpvs/src/netif.c:4739: undefined reference to `rte_eth_bond_link_down_prop_delay_get'
/home/anshul/loadbalancer/dpvs/src/netif.c:4740: undefined reference to `rte_eth_bond_link_up_prop_delay_get'
/home/anshul/loadbalancer/dpvs/src/netif.o: In function `set_bond':
/home/anshul/loadbalancer/dpvs/src/netif.c:5030: undefined reference to `rte_eth_bond_link_down_prop_delay_set'
/home/anshul/loadbalancer/dpvs/src/netif.c:5039: undefined reference to `rte_eth_bond_link_up_prop_delay_set'
collect2: error: ld returned 1 exit status
Makefile:71: recipe for target 'dpvs' failed
make[1]: *** [dpvs] Error 1
make[1]: Leaving directory '/home/anshul/loadbalancer/dpvs/src'
Makefile:33: recipe for target 'all' failed
make: *** [all] Error 1

更新:当前使用的选项dpdk.mk是:

CFLAGS += -march=native \
          -DRTE_MACHINE_CPUFLAG_SSE \
          -DRTE_MACHINE_CPUFLAG_SSE2 \
          -DRTE_MACHINE_CPUFLAG_SSE3 \
          -DRTE_MACHINE_CPUFLAG_SSSE3 \
          -DRTE_MACHINE_CPUFLAG_SSE4_1 \
          -DRTE_MACHINE_CPUFLAG_SSE4_2 

LIBS += -L $(DPDKDIR)/lib
LIBS += -L $(DPDKDIR)/lib/x86_64-linux-gnu/
LIBS += -L $(DPDKDIR)/lib/x86_64-linux-gnu/dpdk/pmds-20.11
 
LIBS += -Wl,--no-as-needed -fvisibility=default \
        -Wl,--whole-archive -lrte_net_vmxnet3 -lrte_net_i40e -lrte_net_ixgbe \
        -lrte_net_e1000 -lrte_net_bnxt -lrte_net_ring -lrte_ip_frag \
        -Wl,--whole-archive -lrte_hash -lrte_kvargs -Wl,-lrte_mbuf -lrte_eal \
        -Wl,--whole-archive -l:librte_net_bond.a -l:librte_ethdev.a \
        -Wl,-lrte_mempool -lrte_ring -lrte_cmdline -lrte_cfgfile -lrte_kni \
        -lrte_mempool_ring -lrte_timer -lrte_net -Wl,-lrte_net_virtio \
        -lrte_pci -lrte_bus_pci -lrte_bus_vdev -lrte_lpm -lrte_pdump \
        -Wl,--no-whole-archive -lrt -lm -ldl -lcrypto -lrte_telemetry

LIBS += -Wl,-rpath,$(DPDKDIR)/lib/x86_64-linux-gnu/

概括:


标签: gccmakefile

解决方案


您面临的问题是由于不当使用库链接。最简单的解决方案是

  1. 下载支持介子的 DPDK 18.11.11 LTS。
  2. 构建 dpdk 库并安装到所需的路径。
  3. 修改 dpvssrc/dpdk.mk以通过 pkg-conf 检查 libdpdk
  4. 修改src/makefile以适应 DPDK 库的更改

在第 3.24 节使用安装的 DPDK 构建应用程序中简要提到了这些步骤的说明

[EDIT-1] 注意:由于@Anshul 对 Makefile 所做的更改没有更新,因此我创建了一个推送请求来支持相同的内容。

src/Makefile 的差异

index 02f288c..f2aefdb 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -34,10 +34,14 @@ DATE_STRING := $(shell date +%Y.%m.%d.%H:%M:%S)
 # same path of THIS Makefile
 SRCDIR := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))

+ifeq ($(shell pkg-config --exists libdpdk && echo 0),0)
+else
 ifeq ($(RTE_SDK),)
        $(error "The variable RTE_SDK is not defined.")
 endif
 include $(RTE_SDK)/mk/rte.vars.mk
+LIBS += -lpthread -lnuma
+endif

 include $(SRCDIR)/config.mk
 include $(SRCDIR)/dpdk.mk
@@ -62,7 +66,6 @@ else
        CFLAGS += -rdynamic
 endif

-LIBS += -lpthread -lnuma

src/dpdk.mk 的差异

 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
+ifeq ($(shell pkg-config --exists libdpdk && echo 0),0)
+
+CFLAGS += -DALLOW_EXPERIMENTAL_API -static $(shell pkg-config --cflags libdpdk)
+LIBS += $(shell pkg-config --libs --static libdpdk)
+
+else

 ifeq ($(RTE_SDK),)
 $(error "The variable RTE_SDK is not defined.")
@@ -58,3 +64,4 @@ LIBS += -Wl,--whole-archive -lrte_pmd_mlx5 -Wl,--no-whole-archive
 LIBS += -libverbs -lmlx5 -lmnl
 endif

+endif

推荐阅读