【发布时间】:2021-04-16 16:49:36
【问题描述】:
我有一个运行 Linux 内核 4.14.78 映像的 QEMU VM。
在主机(96 核的服务器)上,我正在尝试为内核编译一个新的更新,并进行了一些更改。 为了使这个过程更快,我使用主机为目标 VM 进行编译。
为此,我遵循以下步骤:
-
将
/boot/config-4.14.78文件从VM复制到主机 -
将复制的文件放入内核源码根目录,在my中重命名为
.config -
运行
make clean清理它 -
运行
make menuconfig只是为了更新配置 -
运行
make -j$(nproc)
但是,我收到此错误:
AS arch/x86/purgatory/setup-x86_64.o
CC arch/x86/purgatory/sha256.o
AS arch/x86/purgatory/entry64.o
CC arch/x86/purgatory/string.o
In file included from scripts/selinux/mdp/mdp.c:49:
./security/selinux/include/classmap.h:245:2: error: #error New address family defined, please update secclass_map.
245 | #error New address family defined, please update secclass_map.
| ^~~~~
make[3]: *** [scripts/Makefile.host:102: scripts/selinux/mdp/mdp] Error 1
make[2]: *** [scripts/Makefile.build:587: scripts/selinux/mdp] Error 2
make[2]: *** Waiting for unfinished jobs....
In file included from scripts/selinux/genheaders/genheaders.c:19:
./security/selinux/include/classmap.h:245:2: error: #error New address family defined, please update secclass_map.
245 | #error New address family defined, please update secclass_map.
| ^~~~~
CHK scripts/mod/devicetable-offsets.h
make[3]: *** [scripts/Makefile.host:102: scripts/selinux/genheaders/genheaders] Error 1
make[2]: *** [scripts/Makefile.build:587: scripts/selinux/genheaders] Error 2
make[1]: *** [scripts/Makefile.build:587: scripts/selinux] Error 2
make[1]: *** Waiting for unfinished jobs....
我查了一下是什么原因造成的,原来是因为:
include/linux/socket.h:211:#define AF_MAX 44 /* For now.. */
include/linux/socket.h:260:#define PF_MAX AF_MAX
然后,我按照this solution在预处理时打印出PF_MAX的定义,结果PF_MAX就是45:
In file included from scripts/selinux/mdp/mdp.c:49:
./security/selinux/include/classmap.h:247:9: note: #pragma message: 45
247 | #pragma message(STRING(PF_MAX))
| ^~~~~~~
./security/selinux/include/classmap.h:250:2: error: #error New address family defined, please update secclass_map.
250 | #error New address family defined, please update secclass_map.
| ^~~~~
这个45 对我来说毫无意义,因为我刚刚检查过它应该是44。
我想知道构建是否正在考虑主机而不是目标?
P.S.:这些步骤在我的本地机器上运行良好,这是一台 8 核机器,查看内核版本:
uname -a
Linux campes-note 5.4.86 #1 SMP Fri Jan 1 16:26:25 -03 2021 x86_64 x86_64 x86_64 GNU/Linux
更新 1: 我尝试按照上述步骤在不进行任何更改的情况下编译内核,但它也没有编译,我得到了同样的错误。
更新 2:
我发现不知何故,编译正在查看主机/usr/src/linux-headers-x.x.x 文件。
相反,它应该指向与目标相同的版本。
为此,我尝试关注this tutorial,但没有成功。我在本教程所述的某个步骤中遇到问题。
【问题讨论】:
-
它是否可以在没有您对代码进行神奇更改的情况下构建?
-
我只是尝试用干净的内核源代码在这里编译,我得到了同样的错误。实际上,这个错误与我的更改无关。我在 JBD2 日志层上的更改本身很小,我只是添加了一些
printk以查看发生了什么。 -
是的,我已经这样做了。我从:
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.14.78.tar.xz开始下载我要编译的版本。从一个干净的版本中,我遇到了同样的问题。我认为这将是内核头文件或其他东西,通过遵循this,由于与此无关的其他一些错误,我无法遵循这些步骤。 -
太好了,我非常关注
4.14.78,因为这是我正在研究的版本。希望diff4.14.78与 JBD2 层的4.14.214差别不大。 -
那你说的那个补丁可以解决到.78,我现在试试。谢谢。
标签: sockets linux-kernel kernel linux-device-driver device-driver