From: Arnout Vandecappelle via buildroot <buildroot@buildroot.org>
To: Fiona Klute <fiona.klute@gmx.de>, yann.morin@orange.com
Cc: buildroot@buildroot.org, Thomas Perale <thomas.perale@mind.be>,
Christian Stewart <christian@aperture.us>
Subject: Re: [Buildroot] [PATCH 1/1] package/go/go-src: stop forcing binutils-gold dependency on aarch64
Date: Tue, 4 Feb 2025 12:27:17 +0100 [thread overview]
Message-ID: <ee3662e1-3fbf-4a96-addd-b9d748e2a1c8@mind.be> (raw)
In-Reply-To: <c3a16cbe-ae5b-4b68-9713-0fe3bf5888d4@gmx.de>
On 04/02/2025 11:52, Fiona Klute via buildroot wrote:
> Hi Yann!
>
> Am 04.02.25 um 07:26 schrieb yann.morin@orange.com:
>> Fiona, All,
>>
>> On 2025-02-03 13:01 +0100, Fiona Klute via buildroot spake thusly:
>>> From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>
>>>
>>> Go forces the GOLD linker when dynamically linking Go code, because
>>> old versions of BFD caused errors. The issue has been fixed in
>>> Binutils since at least 2.41 according to the upstream description of
>>> the patch added with this commit [1], and now forcing GOLD causes
>>> linking failure if ld.gold is not available. The associated Golang
>>> issue [2] is still open.
>>
>> I have send a patch back a while ago, that allowed to at least work
>> around the issue for affected packages:
>>
>> https://patchwork.ozlabs.org/project/buildroot/
>> patch/876f3a7bb6a2375193fc8f06ab856d2449f83727.1699547993.git.yann.morin@orange.com/
>>
>> This would work for both go-src and go-bin.
>>
>> I needed that for filebeat, but as we no longer use filebeat, I withdrew
>> the patch:
>>
>> https://patchwork.ozlabs.org/project/buildroot/
>> patch/46f20e86fa6c17ada33ede672ffe4229d8bf26a3.1699547993.git.yann.morin@orange.com/
>
> I think that approach should work, I'm just running a test build to verify.
>
> One question though: Is there an existing way to check the Binutils
> version of an external toolchain? For people with Binutils < 2.41 with
The commit message of Yann's patch says "This is supposedly fixed in binutils
2.36". 2.36 is plenty old that we can afford to unconditionally use ld.bfd.
However, if it's only _really_ fixed in 2.41: that one only became the default
for Buildroot in 2024.05. So I don't really think we can count on it if it's
really only fixed in 2.41.
> ld.gold forcing BFD might actually break things, so ideally I'd want to
> make the flag conditional on Binutils >= 2.41 (all Buildroot-built
> toolchains meet that anyway). Or would it be acceptable to simply say
> that people with old external toolchains are on their own?
Using ld.gold only if it is available sounds like a good approach, but I don't
know how easy it is to discover whether or not it is available... Maybe this works:
$(wildcard $(shell $(TARGET_CC) -print-prog-name=ld.gold))
BTW regarding Yann's patch: I would give the use-ld flag unconditionally, not
on a per-package basis. That way, if there really is a problem with bfd, we have
a higher chance of running in to it and therefore fixing it.
Regards,
Arnout
>
> Best regards,
> Fiona
>
>> Regards,
>> Yann E. MORIN.
>>
>>> Import the patch to stop forcing GOLD.
>>>
>>> [1] https://go-review.googlesource.com/c/go/+/391115
>>> [2] https://github.com/golang/go/issues/22040
>>>
>>> Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
>>> ---
>>> ...-binutils-gold-dependency-on-aarch64.patch | 70 +++++++++++++++++++
>>> 1 file changed, 70 insertions(+)
>>> create mode 100644 package/go/go-src/0003-cmd-link-stop-forcing-binutils-
>>> gold-dependency-on-aarch64.patch
>>>
>>> diff --git a/package/go/go-src/0003-cmd-link-stop-forcing-binutils-gold-
>>> dependency-on-aarch64.patch b/package/go/go-src/0003-cmd-link-stop-forcing-
>>> binutils-gold-dependency-on-aarch64.patch
>>> new file mode 100644
>>> index 0000000000..1ba31b6577
>>> --- /dev/null
>>> +++ b/package/go/go-src/0003-cmd-link-stop-forcing-binutils-gold-dependency-
>>> on-aarch64.patch
>>> @@ -0,0 +1,70 @@
>>> +From 6d265b008e3d106b2706645e5a88cd8e2fb98953 Mon Sep 17 00:00:00 2001
>>> +From: Dirk Müller <dirk@dmllr.de>
>>> +Date: Wed, 09 Mar 2022 17:47:23 +0100
>>> +Subject: [PATCH] cmd/link: stop forcing binutils-gold dependency on aarch64
>>> +
>>> +The bfd linker appears to be working just fine at least in version
>>> +2.41 or above. Reject the known broken one instead, which
>>> +avoids an architecture specific linker dependency that
>>> +is cumbersome for distributions.
>>> +
>>> +Fixes #22040.
>>> +
>>> +Change-Id: I9f377e47c22ef20497479c0978c053ed5de46a38
>>> +Upstream: https://go-review.googlesource.com/c/go/+/391115
>>> +Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
>>> +---
>>> +
>>> +diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
>>> +index 2d8f964..fcf0bc7 100644
>>> +--- a/src/cmd/link/internal/ld/lib.go
>>> ++++ b/src/cmd/link/internal/ld/lib.go
>>> +@@ -1670,27 +1670,6 @@
>>> + // Use lld to avoid errors from default linker (issue #38838)
>>> + altLinker = "lld"
>>> + }
>>> +-
>>> +- if ctxt.Arch.InFamily(sys.ARM64) && buildcfg.GOOS == "linux" {
>>> +- // On ARM64, the GNU linker will fail with
>>> +- // -znocopyreloc if it thinks a COPY relocation is
>>> +- // required. Switch to gold.
>>> +- // https://sourceware.org/bugzilla/show_bug.cgi?id=19962
>>> +- // https://go.dev/issue/22040
>>> +- altLinker = "gold"
>>> +-
>>> +- // If gold is not installed, gcc will silently switch
>>> +- // back to ld.bfd. So we parse the version information
>>> +- // and provide a useful error if gold is missing.
>>> +- name, args := flagExtld[0], flagExtld[1:]
>>> +- args = append(args, "-fuse-ld=gold", "-Wl,--version")
>>> +- cmd := exec.Command(name, args...)
>>> +- if out, err := cmd.CombinedOutput(); err == nil {
>>> +- if !bytes.Contains(out, []byte("GNU gold")) {
>>> +- log.Fatalf("ARM64 external linker must be gold (issue
>>> #15696, 22040), but is not: %s", out)
>>> +- }
>>> +- }
>>> +- }
>>> + }
>>> + if ctxt.Arch.Family == sys.ARM64 && buildcfg.GOOS == "freebsd" {
>>> + // Switch to ld.bfd on freebsd/arm64.
>>> +diff --git a/src/make.bash b/src/make.bash
>>> +index b67ae15..7df4910 100755
>>> +--- a/src/make.bash
>>> ++++ b/src/make.bash
>>> +@@ -94,6 +94,16 @@
>>> + ;;
>>> + esac
>>> +
>>> ++# Test for bad bfd.ld
>>> ++if test "$(uname -m)" = "aarch64" && ld -v | grep -E "GNU ld.* 2\.([0-3]|
>>> 40)"; then
>>> ++ echo 'ERROR: Your system uses bfd.LD 2.40 or older which has issues
>>> with dynamic linking on aarch64'
>>> ++ echo 'Consider upgrading or switching to binutils-gold.'
>>> ++ echo
>>> ++ echo 'See https://sourceware.org/bugzilla/show_bug.cgi?id=30437'
>>> ++
>>> ++ exit 1
>>> ++fi
>>> ++
>>> + # Test for bad ld.
>>> + if ld --version 2>&1 | grep 'gold.* 2\.20' >/dev/null; then
>>> + echo 'ERROR: Your system has gold 2.20 installed.'
>>> --
>>> 2.47.2
>>>
>>> _______________________________________________
>>> buildroot mailing list
>>> buildroot@buildroot.org
>>> https://lists.buildroot.org/mailman/listinfo/buildroot
>>
>
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next prev parent reply other threads:[~2025-02-04 11:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-03 12:01 [Buildroot] [PATCH 1/1] package/go/go-src: stop forcing binutils-gold dependency on aarch64 Fiona Klute via buildroot
2025-02-03 12:48 ` Arnout Vandecappelle via buildroot
2025-02-03 13:04 ` Fiona Klute via buildroot
2025-02-03 14:13 ` Arnout Vandecappelle via buildroot
2025-02-03 15:17 ` Fiona Klute via buildroot
2025-02-03 20:08 ` Christian Stewart via buildroot
2025-02-04 3:41 ` Christian Stewart via buildroot
2025-02-04 6:27 ` yann.morin
2025-02-04 14:50 ` Fiona Klute via buildroot
2025-02-04 6:26 ` yann.morin
2025-02-04 10:52 ` Fiona Klute via buildroot
2025-02-04 11:13 ` yann.morin
2025-02-04 11:37 ` Fiona Klute via buildroot
2025-02-04 12:13 ` yann.morin
2025-02-04 14:37 ` Fiona Klute via buildroot
2025-02-04 11:27 ` Arnout Vandecappelle via buildroot [this message]
2025-02-04 14:46 ` Fiona Klute via buildroot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ee3662e1-3fbf-4a96-addd-b9d748e2a1c8@mind.be \
--to=buildroot@buildroot.org \
--cc=arnout@mind.be \
--cc=christian@aperture.us \
--cc=fiona.klute@gmx.de \
--cc=thomas.perale@mind.be \
--cc=yann.morin@orange.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.