sakaki- / gentoo-on-rpi-64bit

Bootable 64-bit Gentoo image for the Raspberry Pi4B, 3B & 3B+, with Linux 5.4, OpenRC, Xfce4, VC4/V3D, camera and h/w codec support, weekly-autobuild binhost
GNU General Public License v3.0
921 stars 126 forks source link

Compile kernel from source error (pie?) #39

Closed skulko closed 6 years ago

skulko commented 6 years ago

I tried to compile kernel from source following the tutorial ("Optional: Compiling a Kernel from Source"). However it always fails with errors like these: MODPOST vmlinux.o ld: arch/arm64/kernel/head.o: relocation R_AARCH64_ABS32 against_kernel_offset_le_lo32' can not be used when making a shared object ld: init/main.o: relocation R_AARCH64_ABS32 against __crc_system_state' can not be used when making a shared object ld: init/version.o: relocation R_AARCH64_ABS32 againstcrc_init_uts_ns' can not be used when making a shared object ld: init/do_mounts.o: relocation R_AARCH64_ABS32 against `crc_name_to_dev_t' can not be used when making a shared object ld: init/init_task.o: relocation R_AARCH64_ABS32 against `__crc_init_task' can not be used when making a shared object

.....

efistubsort.c:(.initksymtab+sort+0x0): dangerous relocation: unsupported relocation efistubsort.c:(.initksymtab+sort+0x8): dangerous relocation: unsupported relocation ld: warning: creating a DT_TEXTREL in a shared object. make: *** [Makefile:1010: vmlinux] Error 1`

I read that PIE might be the problem... but system should be pie compatible?! I have tried different versions 4.9.y, 4.14.y, 4.16.y, all with the same result..

sakaki- commented 6 years ago

If you are running the 1.2.0 release of the gentoo-on-rpi3-64bit image (or have upgraded to same) then yes, your system uses a 17.0 profile , which has the pie flag set by default for gcc. Which gcc version are you using (please post the output of gcc-config --list-profiles)? I have switched (back) to using the 6.4.0 version for kernel compilation on arm64, as I've found the 7.x variants too unstable.

skulko commented 6 years ago

@sakaki- : yes I got the 1.2.0 release and gcc was downgraded to gcc 6.4.0(-r1) when I did echo "sys-devel/gcc -~arm64" >> /etc/portage/package.accept_keywords/gcc I had to compile it locally (not from the binhost) due to use flag mismatch.. but now I am using gcc-6.4.0-r1. It is also working well for other packages from the repository. Only kernel and net-libs/nodejs (which freezes terminal and makes it impossible to login via ssh) are making trouble so far...

skulko commented 6 years ago

dev-libs/elfutils was missing when I ran emerge =raspberrypi-sources-4.14.9999 but I get the same errors as before: ... can not be used when making a shared object ... dangerous relocation: unsupported relocation ld: warning: creating a DT_TEXTREL in a shared object. make: *** [Makefile:1010: vmlinux] Error 1

sakaki- commented 6 years ago

I normally build arm64 kernels using crossdev on my PC, but I'll have a look at the build process natively on the RPi3 next week to see if I can reproduce this.

sakaki- commented 6 years ago

I have reproduced this error now with a local-only build. It doesn't happen on a crossdev-only build (same compiler, same USE flags), so possibly something to do with binutils or similar, rather than gcc per se. Investigating.

sakaki- commented 6 years ago

Yep, binutils - please see https://forums.gentoo.org/viewtopic-p-8199952.html#8199952

skulko commented 6 years ago

Thanks a lot for your investigating!

sakaki- commented 6 years ago

To recap, the "dangerous relocation" problem is a known issue with the version of binutils shipped on the image (2.30). It is fixed upstream in a later binutils release (upstream patch included in 2.30-r2); and (if using gcc-6.4.0 or gcc-6.4.0-r1) the prior version of binutils (2.29.1-r1) also works. So, to compile a kernel locally on your RPi3, you can either:

Apologies for the inconvenience, closing this issue as I believe it is fixed now (and the documentation has been modified to recommend stable binutils as well as stable gcc, which should be a safe default for most users, particularly those who want to use distcc).

Please feel free to reopen if still not working for you. Best, sakaki