Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 539998

Summary: sys-fs/udev forces gold linker on its own, without checking it actually works
Product: Gentoo Linux Reporter: Mart Raudsepp <leio>
Component: [OLD] Core systemAssignee: Gentoo systemd Team <systemd>
Status: CONFIRMED ---    
Severity: normal CC: eike, mahatma, systemd
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
URL: http://cgit.freedesktop.org/systemd/systemd/commit/?id=39c4ead2323b45bbe9866e0f97fd8dcfb8a0bede
See Also: https://bugs.gentoo.org/show_bug.cgi?id=573874
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: compressed build.log
Remove -fuse-ld=gold from linker flags.

Description Mart Raudsepp gentoo-dev 2015-02-13 17:33:48 UTC
sys-fs/udev (and more than likely also systemd, as this is from main systemd configure) fails on ARM with gnu2 tls-dialect, because ld.gold doesn't seem to support those relocations yet. Yet configure merely checks for -Wl,-fuse=gold argument presence on gcc and just explicitly forces it on without testing it actually works for it.
Fortunately the LDFLAGS ordering is so that I can revert it in my own LDFLAGS.

It might be hard to actually test for this, as it might depend on what is being linked - do those relocations get generated by -mtls-dialect=gnu2 or not in the test program.

Either way, I believe in Gentoo it mustn't make the choice itself, as we support choosing the linker (bfd or gold) ourselves, and that choice ought to be honored by things being emerged (linked).
Comment 1 Mart Raudsepp gentoo-dev 2015-02-13 17:39:48 UTC
checking if armv7a-hardfloat-linux-gnueabi-gcc -std=gnu99 supports flag -Wl,-fuse-ld=gold in envvar LDFLAGS... yes

It actually does try to link a program with it, but it consists of only "int main(void) { return 0; }", so that succeeds.

Either way, there's the "In Gentoo we make our own choice of linker" argument :)
Comment 2 Mart Raudsepp gentoo-dev 2015-02-13 17:42:07 UTC
Created attachment 396392 [details]
compressed build.log

/usr/lib/gcc/armv7a-hardfloat-linux-gnueabi/4.9.2/../../../../armv7a-hardfloat-linux-gnueabi/bin/ld.gold: error: ./.libs/libudev-core.a(libsystemd_internal_la-sd-id128.o): unsupported reloc 91 against local symbol
./.libs/libudev-core.a(libsystemd_internal_la-sd-id128.o):sd-id128.c:function sd_id128_get_machine: error: cannot relocate unimplemented reloc R_ARM_TLS_CALL in object file

etc
Comment 3 Anthony Basile gentoo-dev 2015-02-13 18:28:46 UTC
Created attachment 396400 [details, diff]
Remove -fuse-ld=gold from linker flags.

This patch against systemd's codebase should do it.  I haven't tested it, but I'm like 99% sure it will work.  There are some significant difference between bfd and gold and it will bite use it situations like this or if we try to mix static+pie on hardened etc.

@Reporter.  Can you test if it fixes things on your arm board?
Comment 4 Mike Gilbert gentoo-dev 2015-02-14 02:32:04 UTC
Please report this with systemd upstream so that everyone can benefit.
Comment 5 Anthony Basile gentoo-dev 2015-02-14 13:03:11 UTC
(In reply to Mike Gilbert from comment #4)
> Please report this with systemd upstream so that everyone can benefit.

Doubt that will fly.  I'll ask in the #systemd channel why gold and if bfd will work, but I'm not going to open a bug report with systemd people to have it ignored.
Comment 6 Mike Gilbert gentoo-dev 2015-02-14 14:42:52 UTC
(In reply to Anthony Basile from comment #5)
> (In reply to Mike Gilbert from comment #4)
> > Please report this with systemd upstream so that everyone can benefit.
> 
> Doubt that will fly.  I'll ask in the #systemd channel why gold and if bfd
> will work, but I'm not going to open a bug report with systemd people to
> have it ignored.

If you document a build scenario that fails, I think it has a good shot of getting fixed.

Starting with "why do you force gold" might not be the best approach; it presupposes that the problem can only be solved in one way.
Comment 7 Mart Raudsepp gentoo-dev 2015-04-02 16:07:40 UTC
*** Bug 545168 has been marked as a duplicate of this bug. ***
Comment 8 Mart Raudsepp gentoo-dev 2015-04-02 16:12:03 UTC
bug 545168 also shows failure with LDFLAGS="-Wl,--sort-section=alignment"
Comment 9 Rolf Eike Beer archtester 2016-01-13 17:46:39 UTC
This also breaks sparc, i.e. without adding cc_cv_LDFLAGS__Wl__fuse_ld_gold=no to the environment you can't build a working udev (216 or 225) on sparc.
Comment 10 Mike Gilbert gentoo-dev 2016-01-13 18:21:17 UTC
Again, document the failure and open an issue upstream please.
Comment 11 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-02-06 08:11:00 UTC
(In reply to Mart Raudsepp from comment #8)
> bug 545168 also shows failure with LDFLAGS="-Wl,--sort-section=alignment"

You should have made it clear that it means user-provided LDFLAGS.

Well, this is one good reason why we shouldn't let upstream change linker implicitly unless using bfd breaks something.

I'm going to test disabling it. I'm also going to look into upstream tests and possibly submit improvements.
Comment 12 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-02-08 21:12:53 UTC
I've reported the underlying problem upstream [1] and got it fixed in 24hrs. But yes, it's better to complain how bad systemd upstream is than try.

Not saying we shouldn't disable gold anyway. But at least it should now detect correctly that it conflict with user's LDFLAGS.

[1]:https://github.com/systemd/systemd/pull/2541