Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 893956 - dev-lang/go overrides linker, hardcodes sys-devel/binutils' gold on arm
Summary: dev-lang/go overrides linker, hardcodes sys-devel/binutils' gold on arm
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: William Hubbs
URL: https://github.com/golang/go/issues/2...
Whiteboard:
Keywords:
Depends on:
Blocks: tc-directly
  Show dependency tree
 
Reported: 2023-02-11 20:54 UTC by Jannik Glückert
Modified: 2023-09-12 01:27 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
patch to ignore linker workarounds (ld.patch,343 bytes, patch)
2023-02-11 20:54 UTC, Jannik Glückert
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jannik Glückert 2023-02-11 20:54:25 UTC
Created attachment 850386 [details, diff]
patch to ignore linker workarounds

See https://github.com/golang/go/blob/261fe25c83a94fc3defe064baed3944cd3d16959/src/cmd/link/internal/ld/lib.go#L1554

Go forces the linker for various target combinations. Most importantly, it forces gold on arm / arm64 because of a deficiency in bfd that got fixed years ago. See https://sourceware.org/bugzilla/show_bug.cgi?id=19962

This got fixed in binutils 2.36. Furthermore, since we are deprecating gold, this may prevent golang working on arm / arm64 at all.

Upstream has a PR https://github.com/golang/go/pull/49748 , but I don't think we should adopt it as it still uses gold, which is something we want to avoid alltogether.

I'd suggest we just bypass this "linker workaround detection logic" alltogether, see the attached patch. The behaviour in this case is to just invoke CC for linking without a -fuse-ld override.
Comment 1 William Hubbs gentoo-dev 2023-02-13 04:45:22 UTC
I would rather avoid carrying a distro-specific patch if possible. Can
you open an issue upstream and link it here please?

Thanks,

William
Comment 2 William Hubbs gentoo-dev 2023-02-13 04:50:00 UTC
NVM I'll add a link in the upstream pr to this bug.

William
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-02-14 05:40:38 UTC
See https://github.com/golang/go/issues/22040#issuecomment-1429137580. I don't think we can do anything here yet, given Go tests fail when using bfd.
Comment 4 Larry the Git Cow gentoo-dev 2023-02-15 01:00:05 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cd6e76e6b88427411c8c1e8aab9204abc4acdf8c

commit cd6e76e6b88427411c8c1e8aab9204abc4acdf8c
Author:     William Hubbs <williamh@gentoo.org>
AuthorDate: 2023-02-15 00:59:07 +0000
Commit:     William Hubbs <williamh@gentoo.org>
CommitDate: 2023-02-15 00:59:07 +0000

    dev-lang/go: make sure gold is available on arm/arm64
    
    Bug: https://bugs.gentoo.org/893956
    Signed-off-by: William Hubbs <williamh@gentoo.org>

 dev-lang/go/go-1.19.6.ebuild | 3 +++
 dev-lang/go/go-1.20.1.ebuild | 3 +++
 2 files changed, 6 insertions(+)
Comment 5 Andreas K. Hüttel archtester gentoo-dev 2023-08-25 16:19:35 UTC
Given that gold is essentially dead code, this may cause trouble down the road.
Comment 6 Jan Breig 2023-09-07 14:54:52 UTC
According to the upstream issue this should be fixed now with binutils 2.41.
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-09-07 14:56:21 UTC
(In reply to Jan Breig from comment #6)
> According to the upstream issue this should be fixed now with binutils 2.41.

Right, the problem is Go itself needs to learn that.
Comment 8 Andreas K. Hüttel archtester gentoo-dev 2023-09-12 01:27:10 UTC
(In reply to Sam James from comment #7)
> (In reply to Jan Breig from comment #6)
> > According to the upstream issue this should be fixed now with binutils 2.41.
> 
> Right, the problem is Go itself needs to learn that.

https://go-review.googlesource.com/c/go/+/391115

It mostly hangs right now because Go's ci still uses binutils 2.40 and errors out with the patch ... /o\