在ubuntu环境编译dpdk19.11时编译器报如下错误:
[14:12:16]/home/qiaods/linux-ft/include/linux/module.h:133:6: error: ‘init_module’ specifies less restrictive attribute than its target ‘igbuio_pci_init_module’: ‘cold’ [-Werror=missing-attributes]
[14:12:16] 133 | int init_module(void) __attribute__((alias(#initfn)));
[14:12:16] | ^~~~~~~~~~~
[14:12:16]/root/mucse_nic_sdk-yuny-v23.05/driver/dpdk-stable-19.11.6/arm64-armv8a-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.c:641:1: note: in expansion of macro ‘module_init’
[14:12:16] 641 | module_init(igbuio_pci_init_module);
[14:12:16] | ^~~~~~~~~~~
[14:12:16]/root/mucse_nic_sdk-yuny-v23.05/driver/dpdk-stable-19.11.6/arm64-armv8a-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.c:616:1: note: ‘init_module’ target declared here
[14:12:16] 616 | igbuio_pci_init_module(void)
[14:12:16] | ^~~~~~~~~~~~~~~~~~~~~~
[14:12:16]In file included from /root/mucse_nic_sdk-yuny-v23.05/driver/dpdk-stable-19.11.6/arm64-armv8a-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.c:9:
[14:12:16]/home/qiaods/linux-ft/include/linux/module.h:139:7: error: ‘cleanup_module’ specifies less restrictive attribute than its target ‘igbuio_pci_exit_module’: cold’ [-Werror=missing-attributes]
[14:12:16] 139 | void cleanup_module(void) __attribute__((alias(#exitfn)));
[14:12:16] | ^~~~~~~~~~~~~~
[14:12:16]/root/mucse_nic_sdk-yuny-v23.05/driver/dpdk-stable-19.11.6/arm64-armv8a-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.c:642:1: note: in expansion of macro ‘module_exit’
[14:12:16] 642 | module_exit(igbuio_pci_exit_module);
[14:12:16] | ^~~~~~~~~~~
[14:12:16]/root/mucse_nic_sdk-yuny-v23.05/driver/dpdk-stable-19.11.6/arm64-armv8a-linuxapp-gcc/build/kernel/linux/igb_uio/igb_uio.c:636:1: note: ‘cleanup_module’ target declared here
[14:12:16] 636 | igbuio_pci_exit_module(void)
[14:12:16] | ^~~~~~~~~~~~~~~~~~~~~~
错误原因:
这是由高版本GCC编译低版本
glibc
出现的错误。
解决办法:
本环境使用的gcc为gcc-9
可将环境gcc版本降低至gcc-8
执行如下命令更换gcc版本即可:
sudo apt install gcc-8
sudo ln -s /usr/bin/gcc-8 /usr/bin/gcc
更换版本后编译报错消失。