I get the following error when trying to build the kernel with ld.gold - it works fine with ld.bfd
axion linux # make
ld: internal error in target, at /var/tmp/portage/sys-devel/binutils-2.26.1/work/binutils-2.26.1/gold/parameters.h:105
make: *** [scripts/Makefile.build:432: lib/lib-ksyms.o] Error 1
make: *** [Makefile:978: lib] Error 2
I've bisected this back to:
7f2084fa55e6cb61f61b4224d4a8bafaeee55f9f is the first bad commit
Author: Al Viro <firstname.lastname@example.org>
Date: Fri Jan 15 14:01:22 2016 -0500
[kbuild] handle exports in lib-y objects reliably
Collect the symbols exported by anything that goes into lib.a and
add an empty object (lib-exports.o) with explicit undefs for each
of those to obj-y.
That allows to relax the rules regarding the use of exports in
lib-* objects - right now an object with export can be in lib-*
only if we are guaranteed that there always will be users in
built-in parts of the tree, otherwise it needs to be in obj-*.
As the result, we have an unholy mix of lib- and obj- in lib/Makefile
and (especially) in arch/*/lib/Makefile. Moreover, a change in
generic part of the kernel can lead to mysteriously missing exports
on some configs. With this change we don't have to worry about
One side effect is that built-in.o now pulls everything with exports
from the corresponding lib.a (if such exists). That's exactly what
we want for linking vmlinux and fortunately it's almost the only thing
built-in.o is used in. arch/ia64/hp/sim/boot/bootloader is the only
exception and it's easy to get rid of now - just turn everything in
arch/ia64/lib into lib-* and don't bother with arch/ia64/lib/built-in.o
[AV: stylistic fix from Michal folded in]
Acked-by: Michal Marek <email@example.com>
Signed-off-by: Al Viro <firstname.lastname@example.org>
Reverting this patch allows me to compile the kernel with ld.gold again
There is a fix on the go for kbuild composed of two patches:
- all arches: http://marc.info/?l=linux-kernel&m=147667665501297&w=2
and a per architectures one, for x86:
You might want to try those but they might not do for ld.gold:
> > >
> > > When I revert
> > >
> > > 784d5699eddc ("x86: move exports to actual definitions")
> > >
> > > the warnings are gone.
> Also ld.gold doesn't handle linker scripts with empty archives.
> It hits an internal error, see:
We're at rc5 now and I was wondering if you were any closer to getting a fix (or a revert) merged
Most of it is queued in https://git.kernel.org/cgit/linux/kernel/git/mmarek/kbuild.git/log/?h=rc-fixes
that is :
but arch (here x86) bits are missing :
We're really close to 4.9 being released, are there plans to get this fixed before it does?
Created attachment 246881 [details]
This gets it building for me
(In reply to Mike Lothian from comment #6)
> Created attachment 246881 [details]
> This gets it building for me
Mike Lothian's patch works for me too (in addition to the patch in bug 187841).
I'm starting to wish for a Kconfig option to set "-fuse-ld=bfd" globally...
Try link binutils self with ld.gold.
After swith my gentoo box to ld.gold, my sys-kernel/gentoo-sources-4.9.5 happend the same link failed.
Only last this issue:
ld: arch/x86/boot/compressed/head_64.o: warning: relocation in readonly section `.head.text'
ld: warning: creating a DT_TEXTREL in a shared object.
(In reply to henglinli from comment #8)
> Try link binutils self with ld.gold.
> After swith my gentoo box to ld.gold, my sys-kernel/gentoo-sources-4.9.5
> happend the same link failed.
> Only last this issue:
> LD arch/x86/boot/compressed/vmlinux
> ld: arch/x86/boot/compressed/head_64.o: warning: relocation in readonly
> section `.head.text'
> ld: warning: creating a DT_TEXTREL in a shared object.
> ZOFFSET arch/x86/boot/zoffset.h
I also experience the same symptoms with 4.8.17. Although it doesn't limit functionality, it's disturbing.