![从源代码编译内核出现致命错误:函数“part_round_stats”的参数太少](https://linux22.com/image/178475/%E4%BB%8E%E6%BA%90%E4%BB%A3%E7%A0%81%E7%BC%96%E8%AF%91%E5%86%85%E6%A0%B8%E5%87%BA%E7%8E%B0%E8%87%B4%E5%91%BD%E9%94%99%E8%AF%AF%EF%BC%9A%E5%87%BD%E6%95%B0%E2%80%9Cpart_round_stats%E2%80%9D%E7%9A%84%E5%8F%82%E6%95%B0%E5%A4%AA%E5%B0%91.png)
我正在尝试在 CentOS 7 系统上从源代码编译内核。
的输出uname -a
是:
Linux dbn03 3.10.0-957.el7.x86_64 #1 SMP Thu Oct 4 20:48:51 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
以下是我下载源代码并编译它的方法:
wget "http://vault.centos.org/7.6.1810/os/Source/SPackages/kernel-3.10.0-957.el7.src.rpm"
rpm2cpio ./kernel-3.10.0-957.el7.src.rpm | cpio -idmv
make menuconfig
Device Drivers
->Multiple devices driver support (RAID and LVM)
-><*> Block device as cache
make bzImage
make modules
如您所见,我只是尝试使用 BCACHE 模块编译内核。但是,当我执行上面的命令时,出现如下错误:
drivers/md/bcache/request.c:675:3: warning: passing argument 2 of ‘part_round_stats’ makes integer from pointer without a cast [enabled by default]
part_round_stats(cpu, &s->d->disk->part0);
^
In file included from include/linux/blkdev.h:9:0,
from include/linux/blktrace_api.h:4,
from drivers/md/bcache/bcache.h:181,
from drivers/md/bcache/request.c:9:
include/linux/genhd.h:408:13: note: expected ‘int’ but argument is of type ‘struct hd_struct *’
extern void part_round_stats(struct request_queue *q, int cpu, struct hd_struct *part);
^
drivers/md/bcache/request.c:675:3: error: too few arguments to function ‘part_round_stats’
part_round_stats(cpu, &s->d->disk->part0);
^
In file included from include/linux/blkdev.h:9:0,
from include/linux/blktrace_api.h:4,
from drivers/md/bcache/bcache.h:181,
from drivers/md/bcache/request.c:9:
include/linux/genhd.h:408:13: note: declared here
extern void part_round_stats(struct request_queue *q, int cpu, struct hd_struct *part);
看来我收到了警告和错误。
我想我可以忽略这个警告,但这个错误是致命的。在标头中,函数part_round_stats
声明需要三个参数,而在文件中drivers/md/bcache/request.c
,仅将两个参数传递给函数part_round_stats
。
我尝试用谷歌搜索这个问题,但一无所获。
那么我在这里遇到了什么样的问题呢?这是来自linux源代码的错误吗? (我不这么认为......),或者这是版本的某种问题?或者下载的源代码不支持BCACHE模块并且内核开发者留下了致命错误?
答案1
试试这个:
rpm -ivh kernel-3.10.0-957.el7.src.rpm
cd ~/rpmbuild/SOURCES
rpmbuild -bp kernel.spec
cd ~/rpmbuild/BUILD/kernel-3.10.0-957.el7/linux-3.10.0-957.fc32.x86_64
make menuconfig
make bzImage
make modules