DPDK的make方式的编译方法百度下基本都差不多,参考链接在末尾哈。
这里讲述下本人在编译过程中遇到的问题,高手就不用看了,菜鸟的辛酸经历。
1. dpdk编译后没有igb_uio.ko, 没有kmod文件。
问题背景:CentOS Linux release 7.7.1908 + kernel >=3.16 + dpdk20.02
问题现象:dpdk20.02官网文档 中要求kernel >= 3.16, 且官网中说明dpdk20.02可以运行在CentOS7中。但编译过程中没有kmod文件产生,无论手动make编译、meson编译还是dpdk脚本编译。
可能原因:kernel-devel、kernel-headers和内核版本不是对应的。
查看命令:uname -a ; rpm -qa kernel\* | sort
可以通过以下方式安装和系统内核版本一致的:
yum install “kernel-devel-uname-r == $(uname -r)”
yum install “kernel-headers-uname-r == $(uname -r)”
但我的环境里不能升级到和内核一样的版本,因为对应的最新的版本。
解决办法:使用dpdk18.11.6或之前的版本,kernel-devel等版本最新到3.10.0-1062.12.1,所以kernel也是用的3.10
2. 编译问题:
/usr/src/kernels/3.10.0-1062.12.1.el7.x86_64/include/linux/init.h:318:7: 错误:‘cleanup_module’ specifies less restrictive attribute than its target ‘igbuio_pci_exit_module’: ‘cold’ [-Werror=missing-attributes]
318 | void cleanup_module(void) __attribute__((alias(#exitfn)));
| ^~~~~~~~~~~~~~
/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/x86_64-native-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.c:642:1: 附注:in expansion of macro ‘module_exit’
642 | module_exit(igbuio_pci_exit_module);
| ^~~~~~~~~~~
/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/x86_64-native-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.c:636:1: 附注:‘cleanup_module’ target declared here
636 | igbuio_pci_exit_module(void)
| ^~~~~~~~~~~~~~~~~~~~~~
cc1:所有的警告都被当作是错误
make[9]: *** [/usr/src/kernels/3.10.0-1062.12.1.el7.x86_64/scripts/Makefile.build:340:/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/x86_64-native-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.o] 错误 1
make[8]: *** [/usr/src/kernels/3.10.0-1062.12.1.el7.x86_64/Makefile:1316:_module_/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/x86_64-native-linuxapp-gcc/build/kernel/linux/igb_uio] 错误 2
make[7]: *** [Makefile:140:sub-make] 错误 2
make[6]: *** [/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/mk/rte.module.mk:51:igb_uio.ko] 错误 2
make[5]: *** [/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/mk/rte.subdir.mk:37:igb_uio] 错误 2
make[4]: *** [/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/mk/rte.subdir.mk:37:linux] 错误 2
make[3]: *** [/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/mk/rte.sdkbuild.mk:51:kernel] 错误 2
make[2]: *** [/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/mk/rte.sdkroot.mk:101:all] 错误 2
make[1]: *** [/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/mk/rte.sdkinstall.mk:58:pre_install] 错误 2
make: *** [/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/mk/rte.sdkroot.mk:79:install] 错误 2
以及
/usr/src/kernels/3.10.0-1062.12.1.el7.x86_64/include/linux/init.h:312:6: 错误:‘init_module’ specifies less restrictive attribute than its target ‘igbuio_pci_init_module’: ‘cold’ [-Werror=missing-attributes]
312 | int init_module(void) __attribute__((alias(#initfn)));
| ^~~~~~~~~~~
/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/x86_64-native-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.c:641:1: 附注:in expansion of macro ‘module_init’
641 | module_init(igbuio_pci_init_module);
| ^~~~~~~~~~~
/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/x86_64-native-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.c:616:1: 附注:‘init_module’ target declared here
616 | igbuio_pci_init_module(void)
| ^~~~~~~~~~~~~~~~~~~~~~
cc1:所有的警告都被当作是错误
make[9]: *** [/usr/src/kernels/3.10.0-1062.12.1.el7.x86_64/scripts/Makefile.build:340:/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/x86_64-native-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.o] 错误 1
make[8]: *** [/usr/src/kernels/3.10.0-1062.12.1.el7.x86_64/Makefile:1316:_module_/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/x86_64-native-linuxapp-gcc/build/kernel/linux/igb_uio] 错误 2
make[7]: *** [Makefile:140:sub-make] 错误 2
make[6]: *** [/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/mk/rte.module.mk:51:igb_uio.ko] 错误 2
make[5]: *** [/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/mk/rte.subdir.mk:37:igb_uio] 错误 2
make[4]: *** [/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/mk/rte.subdir.mk:37:linux] 错误 2
make[3]: *** [/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/mk/rte.sdkbuild.mk:51:kernel] 错误 2
make[2]: *** [/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/mk/rte.sdkroot.mk:101:all] 错误 2
make[1]: *** [/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/mk/rte.sdkinstall.mk:58:pre_install] 错误 2
make: *** [/home/samba_share/spdk/spdk-20.01/dpdk/dpdk-stable-18.11.6/mk/rte.sdkroot.mk:79:install] 错误 2
解决办法:在/usr/src/kernels/3.10.0-1062.12.1.el7.x86_64/include/linux/init.h中的
318 | void cleanup_module(void) __attribute__((alias(#exitfn))); ===》 改成
void cleanup_module(void) __cold __attribute__((alias(#exitfn)));
312 | int init_module(void) __attribute__((alias(#initfn))); ===》 改成
int init_module(void) __cold __attribute__((alias(#initfn)));
dpdk官方文档:
DPDK20.02
DPDK18.11.6
参考链接:
https://blog.csdn.net/hn3e81/article/details/93054030?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task
https://blog.csdn.net/javaxflinux/article/details/86523870?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task
https://blog.csdn.net/cloudvtech/article/details/80221236?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task