我在尝试从源代码编译内核时遇到错误。我环顾四周,但没有找到任何可以专门处理我所看到的错误的内容。
我正在使用指南在树莓派上网站来完成整个过程,我只是按照说明进行操作。我正在将其编译为运行 Raspbian Jessie 的 Raspberry Pi 2 板上的 Raspberry Pi model B(第一代)的内核。无论内核是用于原始内核还是 Raspberry Pi 2,这些错误都会发生。以下是我正在做和看到的内容:
pi@rpi4 ~ $ git clone --depth=1 https://github.com/raspberrypi/linux
Cloning into 'linux'...
remote: Counting objects: 52876, done.
remote: Compressing objects: 100% (50355/50355), done.
remote: Total 52876 (delta 4013), reused 17588 (delta 1852), pack-reused 0
Receiving objects: 100% (52876/52876), 142.61 MiB | 3.87 MiB/s, done.
Resolving deltas: 100% (4013/4013), done.
Checking connectivity... done.
Checking out files: 100% (49946/49946), done.
pi@rpi4 ~ $ cd linux
pi@rpi4 ~/linux $ KERNEL=kernel
pi@rpi4 ~/linux $ make bcmrpi_defconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/zconf.lex.c
SHIPPED scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
#
# configuration written to .config
#
pi@rpi4 ~/linux $ time make -j5 zImage modules dtbs
scripts/kconfig/conf --silentoldconfig Kconfig
CHK include/config/kernel.release
WRAP arch/arm/include/generated/asm/bitsperlong.h
WRAP arch/arm/include/generated/asm/cputime.h
....................
CC mm/frontswap.o
In file included from include/linux/sched.h:27:0,
from kernel/rcu/tree.c:37:
include/linux/mm_types.h:209:8: internal compiler error: Segmentation fault
struct page_frag {
^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.9/README.Bugs> for instructions.
CC [M] fs/9p/v9fs.o
CC [M] crypto/ctr.o
CC [M] fs/9p/fid.o
CC mm/dmapool.o
CC [M] crypto/gcm.o
CC [M] fs/9p/xattr.o
CC [M] fs/9p/xattr_user.o
CC mm/slub.o
CC [M] fs/9p/xattr_trusted.o
CC [M] fs/9p/acl.o
CC [M] crypto/ccm.o
LD [M] fs/9p/9p.o
CC fs/autofs4/init.o
The bug is not reproducible, so it is likely a hardware or OS problem.
scripts/Makefile.build:258: recipe for target 'kernel/rcu/tree.o' failed
make[2]: *** [kernel/rcu/tree.o] Error 1
scripts/Makefile.build:403: recipe for target 'kernel/rcu' failed
make[1]: *** [kernel/rcu] Error 2
Makefile:947: recipe for target 'kernel' failed
make: *** [kernel] Error 2
make: *** Waiting for unfinished jobs....
LD fs/btrfs/built-in.o
CC [M] fs/btrfs/super.o
CC fs/autofs4/inode.o
....................
CC fs/fscache/netfs.o
CC fs/f2fs/segment.o
CC [M] fs/fuse/dir.o
In file included from include/linux/mm.h:921:0,
from include/linux/pagemap.h:7,
from include/linux/fscache.h:23,
from include/linux/fscache-cache.h:21,
from fs/fscache/internal.h:31,
from fs/fscache/netfs.c:15:
include/linux/vmstat.h: In function ‘count_vm_event’:
include/linux/vmstat.h:41:2: internal compiler error: Segmentation fault
this_cpu_inc(vm_event_states.event[item]);
^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.9/README.Bugs> for instructions.
CC [M] fs/btrfs/raid56.o
The bug is not reproducible, so it is likely a hardware or OS problem.
scripts/Makefile.build:258: recipe for target 'fs/fscache/netfs.o' failed
make[2]: *** [fs/fscache/netfs.o] Error 1
scripts/Makefile.build:403: recipe for target 'fs/fscache' failed
make[1]: *** [fs/fscache] Error 2
make[1]: *** Waiting for unfinished jobs....
CC [M] fs/btrfs/uuid-tree.o
CC [M] fs/fuse/file.o
CC [M] fs/fuse/inode.o
CC fs/ext4/extents.o
CC [M] fs/btrfs/props.o
CC fs/f2fs/recovery.o
CC [M] fs/fuse/control.o
cc1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.9/README.Bugs> for instructions.
CC fs/f2fs/debug.o
CC [M] fs/btrfs/hash.o
CC [M] fs/btrfs/acl.o
CC [M] fs/fuse/cuse.o
The bug is not reproducible, so it is likely a hardware or OS problem.
scripts/Makefile.build:258: recipe for target 'fs/f2fs/recovery.o' failed
make[2]: *** [fs/f2fs/recovery.o] Error 1
make[2]: *** Waiting for unfinished jobs....
LD [M] fs/fuse/fuse.o
CC fs/ext4/ext4_jbd2.o
scripts/Makefile.build:403: recipe for target 'fs/f2fs' failed
make[1]: *** [fs/f2fs] Error 2
CC fs/ext4/migrate.o
....................
LD fs/ext4/built-in.o
Makefile:947: recipe for target 'fs' failed
make: *** [fs] Error 2
real 11m41.081s
user 43m2.340s
sys 2m1.510s
pi@rpi4 ~/linux $ ccache -s
cache directory /home/pi/.ccache
cache hit (direct) 0
cache hit (preprocessed) 0
cache miss 0
files in cache 0
cache size 0 Kbytes
max cache size 1.0 Gbytes
正如您所看到的,编译过程在构建文件系统组件和模块时失败。 Ccache 似乎也没有拾取任何文件。我看到它说存在内部编译器错误,可能是由于硬件问题造成的,但我不确定这是什么。
问题是,我也在我的笔记本电脑上编译内核和模块,这是一台运行 Ubuntu 并安装了交叉编译工具链的 x86-64 机器。笔记本电脑编译内核的成功率似乎要高得多。我会用它来完成工作,但我正在开发一个在 Raspberry Pi 本身上进行编译时更有意义的项目。我一直在寻找解决方案,但似乎找不到,而且它阻碍了一个相当重要的(对我来说)项目。
答案1
不幸的是,这似乎是一个更系统范围的问题。重新安装操作系统解决了这个问题,我改用 NOOBS 或直接对操作系统进行映像。这不是最优雅的解决方案,但你已经有了。