2

I'm encountering errors while trying to compile the kernel from source. I've looked around but I'm not finding anything that deals with the error I'm seeing specifically.

I am using the guide on the Raspberry Pi website to go through the process and am just following the instructions. I'm compiling this as a kernel for the Raspberry Pi model B (first generation) on a Raspberry Pi 2 board running Raspbian Jessie. Here's what I'm doing and seeing:

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

As you can see, the compilation process fails out around the time when file system components and modules are being built. Ccache does not seem to be picking up any files, either. I see that it says there's an internal compiler error that may be due to a hardware problem, but I'm not sure what this would be.

The thing is, I have also been compiling the kernel and modules on my laptop, an x86-64 machine running Ubuntu with the cross-compile toolchain installed. The laptop seems to have a much higher success rate at compiling the kernel. I'd use it for the job, but I'm working on a project that makes more sense when compiling on the Raspberry Pis themselves.

1

If you suspect a hardware problem, try running cpu and RAM tests to confirm it:

sudo apt-get install memtester
memtester

I would probably run fsck as well, even though filesystem errors resulting in segfaults are unlikely.

Finally, I would assume that the bug is specific to the compiler and try to install a different version of gcc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.