Bug 177741 - [regression] [bisected] Kernel no longer builds with ld.gold
Summary: [regression] [bisected] Kernel no longer builds with ld.gold
Status: RESOLVED CODE_FIX
Alias: None
Product: Other
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: other_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-17 00:45 UTC by Mike Lothian
Modified: 2018-02-12 11:36 UTC (History)
5 users (show)

See Also:
Kernel Version: 4.9-rc1
Tree: Mainline
Regression: No


Attachments
This gets it building for me (367 bytes, application/octet-stream)
2016-12-05 08:59 UTC, Mike Lothian
Details

Description Mike Lothian 2016-10-17 00:45:33 UTC
I get the following error when trying to build the kernel with ld.gold - it works fine with ld.bfd

axion linux # make 
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  CHK     kernel/config_data.h
  EXPORTS drivers/firmware/efi/libstub/lib-ksyms.o
  LD      drivers/firmware/efi/libstub/built-in.o
  LD      drivers/firmware/efi/built-in.o
  LD      drivers/firmware/built-in.o
  LD      drivers/built-in.o
  EXPORTS lib/lib-ksyms.o
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[1]: *** [scripts/Makefile.build:432: lib/lib-ksyms.o] Error 1
make: *** [Makefile:978: lib] Error 2
Comment 1 Mike Lothian 2016-10-17 23:25:48 UTC
I've bisected this back to:

7f2084fa55e6cb61f61b4224d4a8bafaeee55f9f is the first bad commit
commit 7f2084fa55e6cb61f61b4224d4a8bafaeee55f9f
Author: Al Viro <viro@zeniv.linux.org.uk>
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
    that anymore.
    
    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
    anymore.
    
    [AV: stylistic fix from Michal folded in]
    
    Acked-by: Michal Marek <mmarek@suse.cz>
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Reverting this patch allows me to compile the kernel with ld.gold again
Comment 2 Alban Browaeys 2016-10-21 12:18:20 UTC
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:
- http://marc.info/?l=linux-kernel&m=147669851906489&w=2

You might want to try those but they might not do for ld.gold: 
http://marc.info/?l=linux-kernel&m=147682325012335&w=2 tells
> > > 
> > > 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: 
> https://sourceware.org/bugzilla/show_bug.cgi?id=20693
Comment 3 Mike Lothian 2016-11-15 13:34:48 UTC
We're at rc5 now and I was wondering if you were any closer to getting a fix (or a revert) merged
Comment 5 Mike Lothian 2016-12-01 15:19:20 UTC
We're really close to 4.9 being released, are there plans to get this fixed before it does?
Comment 6 Mike Lothian 2016-12-05 08:59:33 UTC
Created attachment 246881 [details]
This gets it building for me
Comment 7 Matt Whitlock 2016-12-13 02:25:33 UTC
(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...
Comment 8 henglinli 2017-01-21 19:30:51 UTC
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
Comment 9 Dwokfur 2017-01-31 16:34:55 UTC
(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.

Note You need to log in before you can comment on or make changes to this bug.