我通过 下载了 ubuntu 源代码git clone git://kernel.ubuntu.com/ubuntu/ubuntu-focal.git
。因为我想使用特定的版本,所以我执行了 git checkout Ubuntu-5.4.0-42.46 (此版本是 ubuntu 安装 .iso 中使用的版本。请参阅此处的相关问题:我应该使用哪个 ubuntu 源版本来添加一些调试打印?(用于 ubuntu 启动调试))
git-checkout 之后git log
显示以下结果:
commit 98c4545e2d65ed35c31056f72c4da20f6b5ea0d0 (HEAD, tag: Ubuntu-5.4.0-42.46)
Author: Khalid Elmously <[email protected]>
Date: Thu Jul 9 19:50:26 2020 -0400
UBUNTU: Ubuntu-5.4.0-42.46
Signed-off-by: Khalid Elmously <[email protected]>
为了构建内核,我执行了ARCH=arm64 CROSS_COMPILE=aarch64-none-elf- make defconfig
和ARCH=arm64 CROSS_COMPILE=aarch64-none-elf- make -j24 Image
。但这会给我下面的编译错误。可能是什么问题?
.
.
CC mm/interval_tree.o
CC drivers/base/regmap/regcache.o
CC kernel/time/posix-cpu-timers.o
CC mm/list_lru.o
CC block/blk-mq.o
AS arch/arm64/lib/memchr.o
CC fs/ext4/migrate.o
security/security.c: In function 'security_add_hooks':
security/security.c:477:25: error: 'struct security_hook_heads' has no member named 'socket_getpeersec_stream'
477 | &security_hook_heads.socket_getpeersec_stream)
| ^
CC kernel/time/posix-clock.o
AS arch/arm64/lib/memcmp.o
security/security.c: In function 'security_setprocattr':
CC arch/arm64/kvm/../../../virt/kvm/arm/vgic/vgic-v2.o
security/security.c:2058:27: error: 'union security_list_options' has no member named 'socket_getpeersec_stream'
2058 | socket_getpeersec_stream.socket_getpeersec_stream = NULL;
| ^
In file included from ./include/linux/timer.h:5,
from ./include/linux/workqueue.h:9,
from ./include/linux/bpf.h:9,
from security/security.c:13:
security/security.c:2060:25: error: 'struct security_hook_heads' has no member named 'socket_getpeersec_stream'
2060 | &security_hook_heads.socket_getpeersec_stream,
| ^
./include/linux/list.h:857:12: note: in definition of macro 'hlist_entry_safe'
857 | ({ typeof(ptr) ____ptr = (ptr); \
| ^~~
security/security.c:2059:3: note: in expansion of macro 'hlist_for_each_entry'
2059 | hlist_for_each_entry(hp,
| ^~~~~~~~~~~~~~~~~~~~
security/security.c:2060:25: error: 'struct security_hook_heads' has no member named 'socket_getpeersec_stream'
2060 | &security_hook_heads.socket_getpeersec_stream,
| ^
./include/linux/list.h:857:28: note: in definition of macro 'hlist_entry_safe'
857 | ({ typeof(ptr) ____ptr = (ptr); \
| ^~~
security/security.c:2059:3: note: in expansion of macro 'hlist_for_each_entry'
2059 | hlist_for_each_entry(hp,
| ^~~~~~~~~~~~~~~~~~~~
In file included from ./include/linux/list.h:9,
from ./include/linux/timer.h:5,
from ./include/linux/workqueue.h:9,
from ./include/linux/bpf.h:9,
from security/security.c:13:
./include/linux/kernel.h:993:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
993 | void *__mptr = (void *)(ptr); \
| ^
./include/linux/list.h:847:40: note: in expansion of macro 'container_of'
847 | #define hlist_entry(ptr, type, member) container_of(ptr,type,member)
| ^~~~~~~~~~~~
.
.
当我对 linux-5.4.21 源执行相同操作时,它可以编译成功。
答案1
我发现 ubuntu 有自己的构建整个 ubuntu (包括内核)的方法。如下所示:https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel
arm64 案例的正确方法是(来自上面的页面)
LANG=C fakeroot debian/rules ARCH=arm64 clean
# quicker build:
LANG=C fakeroot debian/rules ARCH=arm64 binary-headers binary-generic binary-perarch
# if you need linux-tools or lowlatency kernel, run instead:
LANG=C fakeroot debian/rules ARCH=arm64 binary
您可以使用以下命令(从上面的页面)添加调试信息:
sudo apt-get install pkg-config-dbgsym
LANG=C fakeroot debian/rules clean
LANG=C fakeroot debian/rules binary-headers binary-generic binary-perarch skipdbg=false