-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/link: stop requiring gold on arm64 when GNU ld is fixed #22040
Comments
For background see #15696 and https://sourceware.org/bugzilla/show_bug.cgi?id=19962. I think that we have to require gold until the GNU ld bug is fixed. I'm going to close this issue since I don't see anything we can do. Please comment if you disagree. |
@ianlancetaylor AFAIK SWBZ is related only to ARM32, my issues is on ARM64. I could be easily wrong though or there is same issues on ARM64, I'm not that familiar with binutils\s ld code base. Also I would like to keep this opened, even if this turns out to be fully binutils bug. As I think that the workaround code should be reverted when the issue is fixed in ld(whatever for ARM32/64 or both). |
OK, I guess. |
I have a situation where the gold linker will not be available on an ARM64 linux target and would like to avoid the gold dependency so I can package Go there. The referenced binutils bug https://sourceware.org/bugzilla/show_bug.cgi?id=19962 has a proposed patch: --- a/bfd/elf32-arm.c
+++ a/bfd/elf32-arm.c
@@ -14112,11 +14112,15 @@ elf32_arm_adjust_dynamic_symbol (struct bfd_link_info * info,
s = bfd_get_linker_section (dynobj, ".dynbss");
BFD_ASSERT (s != NULL);
- /* We must generate a R_ARM_COPY reloc to tell the dynamic linker to
- copy the initial value out of the dynamic object and into the
- runtime process image. We need to remember the offset into the
+ /* If allowed, we must generate a R_ARM_COPY reloc to tell the dynamic
+ linker to copy the initial value out of the dynamic object and into
+ the runtime process image. We need to remember the offset into the
.rel(a).bss section we are going to use. */
- if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
+ if (info->nocopyreloc == 0
+ && (h->root.u.def.section->flags & SEC_ALLOC) != 0
+ /* PR 16177: A copy is only needed if the input section is readonly. */
+ && (h->root.u.def.section->flags & SEC_READONLY) == 0
+ && h->size != 0)
{
asection *srel; @ianlancetaylor @crawshaw Would it be possible to get some feedback from the Go team on whether that patch addresses the issue for Go? With that it might be possible to get the patch or a revised patch accepted by upstream binutils. |
I don't see why that patch will help, as as far as I can see it only affects arm, not arm64. |
A proposed patch for aarch64 was added to https://sourceware.org/bugzilla/show_bug.cgi?id=19962 on 2020-08-24: --- a/bfd/elfnn-aarch64.c
+++ a/bfd/elfnn-aarch64.c
@@ -7474,7 +7474,10 @@ elfNN_aarch64_adjust_dynamic_symbol (struct bfd_link_info *info,
s = htab->root.sdynbss;
srel = htab->root.srelbss;
}
- if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
+ if ((h->root.u.def.section->flags & SEC_ALLOC)
+ && (h->root.u.def.section->flags & SEC_READONLY)
+ && h->size != 0)
+
{
srel->size += RELOC_SIZE (htab);
h->needs_copy = 1; |
The GNU ld issue has been marked as fixed (according to the last comment the issue is not present in binutils 2.36 and higher). Would it be possible to revisit the gold linker requirement at this point? The OpenWrt toolchain does not include the gold linker and I have been advising our packages to patch out Go plugins to avoid triggering this requirement (crowdsec, rclone). |
I suggest that for now we change to request gold but not give an error if gold is not available. Want to test and send a patch for that? It's cmd/link/internal/ld/lib.go. |
I’ll try to find some time to work on this patch - thanks 🙂 |
COPY relocation handling on ARM/ARM64 has been fixed in recent versions of the GNU linker. This switches to gold only if gold is available. Fixes golang#22040.
Change https://golang.org/cl/366279 mentions this issue: |
Change https://go.dev/cl/391115 mentions this issue: |
This PR merge plan? |
Hi all, I am the package maintainer for Go on Gentoo Linux. |
Can someone investigate to see exactly when the GNU linker was fixed? There are two different patches submitted for this (https://go.dev/cl/366279, https://go.dev/cl/391115) and they both seem to have some discussion. In particular, do you have concerns about the approach in https://go.dev/cl/366279? |
@ianlancetaylor I am not an expert in the toolchain, so hopefully someone else will join this issue and comment. The position of the people wanting me to diverge from what upstream is |
it was back up now, so I updated. |
Tests in all.bash pass with the updated CL https://go.dev/cl/391115/4. On SUSE and openSUSE we have applied this patch from go1.16 through go1.21 without issues. |
Upstream has updated the Go compiler to not use gold when building for arm, and is waiting for a fix to binutils (released in 2.41) before doing the same for aarch64.[1] Based on the above, it does not appear that golang/go#49748 will be merged. This removes the patch from that pull request. [1]: golang/go#22040 Signed-off-by: Jeffery To <jeffery.to@gmail.com> (cherry picked from commit a80af7e)
Upstream has updated the Go compiler to not use gold when building for arm, and is waiting for a fix to binutils (released in 2.41) before doing the same for aarch64.[1] Based on the above, it does not appear that golang/go#49748 will be merged. This removes the patch from that pull request. [1]: golang/go#22040 Signed-off-by: Jeffery To <jeffery.to@gmail.com> (cherry picked from commit a80af7e)
Upstream has updated the Go compiler to not use gold when building for arm, and is waiting for a fix to binutils (released in 2.41) before doing the same for aarch64.[1] Based on the above, it does not appear that golang/go#49748 will be merged. This removes the patch from that pull request. [1]: golang/go#22040 Signed-off-by: Jeffery To <jeffery.to@gmail.com>
Upstream has updated the Go compiler to not use gold when building for arm, and is waiting for a fix to binutils (released in 2.41) before doing the same for aarch64.[1] Based on the above, it does not appear that golang/go#49748 will be merged. This removes the patch from that pull request. [1]: golang/go#22040 Signed-off-by: Jeffery To <jeffery.to@gmail.com>
Upstream has updated the Go compiler to not use gold when building for arm, and is waiting for a fix to binutils (released in 2.41) before doing the same for aarch64.[1] Based on the above, it does not appear that golang/go#49748 will be merged. This removes the patch from that pull request. [1]: golang/go#22040 Signed-off-by: Jeffery To <jeffery.to@gmail.com>
Are there any progress on landing one of the proposed solutions to remove the "gold" check? Lots of projects are ending up patching the go code. |
Upstream has updated the Go compiler to not use gold when building for arm, and is waiting for a fix to binutils (released in 2.41) before doing the same for aarch64.[1] Based on the above, it does not appear that golang/go#49748 will be merged. This removes the patch from that pull request. [1]: golang/go#22040 Signed-off-by: Jeffery To <jeffery.to@gmail.com>
gold linker seems to be abandoned upstream, and is only required for arm due to a bug in old bfd linker. But there are no gold linker for riscv64, so only pull in gold on arm/arm64. fixes: k0sproject#4665 ref: golang/go#22040 Signed-off-by: Natanael Copa <ncopa@mirantis.com>
go1.21 and up have a patch that enforces the use of ld.gold to work around a bug in GNU binutils. See; - golang/go#22040. - golang/go@cd77738 Fedora 41 and up has a fixed version of binutils, and no longer requires that patch, but will fail without ld.gold installed; /usr/bin/gcc -Wl,-z,now -Wl,-z,nocopyreloc -fuse-ld=gold -o $WORK/b001/exe/a.out -rdynamic /tmp/go-link-1738353519/go.o /tmp/go-link-1738353519/000000.o /tmp/go-link-1738353519/000001.o /tmp/go-link-1738353519/000002.o /tmp/go-link-1738353519/000003.o /tmp/go-link-1738353519/000004.o /tmp/go-link-1738353519/000005.o /tmp/go-link-1738353519/000006.o /tmp/go-link-1738353519/000007.o /tmp/go-link-1738353519/000008.o /tmp/go-link-1738353519/000009.o /tmp/go-link-1738353519/000010.o /tmp/go-link-1738353519/000011.o /tmp/go-link-1738353519/000012.o /tmp/go-link-1738353519/000013.o /tmp/go-link-1738353519/000014.o /tmp/go-link-1738353519/000015.o /tmp/go-link-1738353519/000016.o /tmp/go-link-1738353519/000017.o /tmp/go-link-1738353519/000018.o /tmp/go-link-1738353519/000019.o /tmp/go-link-1738353519/000020.o /tmp/go-link-1738353519/000021.o /tmp/go-link-1738353519/000022.o /tmp/go-link-1738353519/000023.o /tmp/go-link-1738353519/000024.o -O2 -g -lresolv -O2 -g -lpthread -O2 -g -ldl -O2 -g collect2: fatal error: cannot find 'ld' Fedora's build of Go carries a patch for that, but it's not (yet) in upstream; - https://src.fedoraproject.org/rpms/golang/blob/a867bd88a656c1d6e91e7b18bab696dc3fcf1e77/f/0006-Default-to-ld.bfd-on-ARM64.patch - https://src.fedoraproject.org/rpms/golang/c/a867bd88a656c1d6e91e7b18bab696dc3fcf1e77?branch=rawhide - As a workaround; install binutils-gold Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
go1.21 and up have a patch that enforces the use of ld.gold to work around a bug in GNU binutils. See; - golang/go#22040. - golang/go@cd77738 Fedora 41 and up has a fixed version of binutils, and no longer requires that patch, but will fail without ld.gold installed; /usr/bin/gcc -Wl,-z,now -Wl,-z,nocopyreloc -fuse-ld=gold -o $WORK/b001/exe/a.out -rdynamic /tmp/go-link-1738353519/go.o /tmp/go-link-1738353519/000000.o /tmp/go-link-1738353519/000001.o /tmp/go-link-1738353519/000002.o /tmp/go-link-1738353519/000003.o /tmp/go-link-1738353519/000004.o /tmp/go-link-1738353519/000005.o /tmp/go-link-1738353519/000006.o /tmp/go-link-1738353519/000007.o /tmp/go-link-1738353519/000008.o /tmp/go-link-1738353519/000009.o /tmp/go-link-1738353519/000010.o /tmp/go-link-1738353519/000011.o /tmp/go-link-1738353519/000012.o /tmp/go-link-1738353519/000013.o /tmp/go-link-1738353519/000014.o /tmp/go-link-1738353519/000015.o /tmp/go-link-1738353519/000016.o /tmp/go-link-1738353519/000017.o /tmp/go-link-1738353519/000018.o /tmp/go-link-1738353519/000019.o /tmp/go-link-1738353519/000020.o /tmp/go-link-1738353519/000021.o /tmp/go-link-1738353519/000022.o /tmp/go-link-1738353519/000023.o /tmp/go-link-1738353519/000024.o -O2 -g -lresolv -O2 -g -lpthread -O2 -g -ldl -O2 -g collect2: fatal error: cannot find 'ld' Fedora's build of Go carries a patch for that, but it's not (yet) in upstream; - https://src.fedoraproject.org/rpms/golang/blob/a867bd88a656c1d6e91e7b18bab696dc3fcf1e77/f/0006-Default-to-ld.bfd-on-ARM64.patch - https://src.fedoraproject.org/rpms/golang/c/a867bd88a656c1d6e91e7b18bab696dc3fcf1e77?branch=rawhide - As a workaround; install binutils-gold Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
go1.21 and up have a patch that enforces the use of ld.gold to work around a bug in GNU binutils. See; - golang/go#22040. - golang/go@cd77738 Fedora 41 and up has a fixed version of binutils, and no longer requires that patch, but will fail without ld.gold installed; /usr/bin/gcc -Wl,-z,now -Wl,-z,nocopyreloc -fuse-ld=gold -o $WORK/b001/exe/a.out -rdynamic /tmp/go-link-1738353519/go.o /tmp/go-link-1738353519/000000.o /tmp/go-link-1738353519/000001.o /tmp/go-link-1738353519/000002.o /tmp/go-link-1738353519/000003.o /tmp/go-link-1738353519/000004.o /tmp/go-link-1738353519/000005.o /tmp/go-link-1738353519/000006.o /tmp/go-link-1738353519/000007.o /tmp/go-link-1738353519/000008.o /tmp/go-link-1738353519/000009.o /tmp/go-link-1738353519/000010.o /tmp/go-link-1738353519/000011.o /tmp/go-link-1738353519/000012.o /tmp/go-link-1738353519/000013.o /tmp/go-link-1738353519/000014.o /tmp/go-link-1738353519/000015.o /tmp/go-link-1738353519/000016.o /tmp/go-link-1738353519/000017.o /tmp/go-link-1738353519/000018.o /tmp/go-link-1738353519/000019.o /tmp/go-link-1738353519/000020.o /tmp/go-link-1738353519/000021.o /tmp/go-link-1738353519/000022.o /tmp/go-link-1738353519/000023.o /tmp/go-link-1738353519/000024.o -O2 -g -lresolv -O2 -g -lpthread -O2 -g -ldl -O2 -g collect2: fatal error: cannot find 'ld' Fedora's build of Go carries a patch for that, but it's not (yet) in upstream; - https://src.fedoraproject.org/rpms/golang/blob/a867bd88a656c1d6e91e7b18bab696dc3fcf1e77/f/0006-Default-to-ld.bfd-on-ARM64.patch - https://src.fedoraproject.org/rpms/golang/c/a867bd88a656c1d6e91e7b18bab696dc3fcf1e77?branch=rawhide - As a workaround; install binutils-gold Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
…on arm64 go1.21 and up have a patch that enforces the use of ld.gold to work around a bug in GNU binutils. See; - golang/go#22040. - golang/go@cd77738 Fedora 41 and up has a fixed version of binutils, and no longer requires that patch, but will fail without ld.gold installed; /usr/bin/gcc -Wl,-z,now -Wl,-z,nocopyreloc -fuse-ld=gold -o $WORK/b001/exe/a.out -rdynamic /tmp/go-link-1738353519/go.o /tmp/go-link-1738353519/000000.o /tmp/go-link-1738353519/000001.o /tmp/go-link-1738353519/000002.o /tmp/go-link-1738353519/000003.o /tmp/go-link-1738353519/000004.o /tmp/go-link-1738353519/000005.o /tmp/go-link-1738353519/000006.o /tmp/go-link-1738353519/000007.o /tmp/go-link-1738353519/000008.o /tmp/go-link-1738353519/000009.o /tmp/go-link-1738353519/000010.o /tmp/go-link-1738353519/000011.o /tmp/go-link-1738353519/000012.o /tmp/go-link-1738353519/000013.o /tmp/go-link-1738353519/000014.o /tmp/go-link-1738353519/000015.o /tmp/go-link-1738353519/000016.o /tmp/go-link-1738353519/000017.o /tmp/go-link-1738353519/000018.o /tmp/go-link-1738353519/000019.o /tmp/go-link-1738353519/000020.o /tmp/go-link-1738353519/000021.o /tmp/go-link-1738353519/000022.o /tmp/go-link-1738353519/000023.o /tmp/go-link-1738353519/000024.o -O2 -g -lresolv -O2 -g -lpthread -O2 -g -ldl -O2 -g collect2: fatal error: cannot find 'ld' Fedora's build of Go carries a patch for that, but it's not (yet) in upstream; - https://src.fedoraproject.org/rpms/golang/blob/a867bd88a656c1d6e91e7b18bab696dc3fcf1e77/f/0006-Default-to-ld.bfd-on-ARM64.patch - https://src.fedoraproject.org/rpms/golang/c/a867bd88a656c1d6e91e7b18bab696dc3fcf1e77?branch=rawhide - As a workaround; install binutils-gold Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This is the equivalent of docker/containerd-packaging#390 for containerd packages, but unlike for containerd packages, we currently do not run into this issue when building docker-ce packages. We're installing this as a precaution, but perhaps it's not needed. go1.21 and up have a patch that enforces the use of ld.gold to work around a bug in GNU binutils. See; - golang/go#22040. - golang/go@cd77738 Fedora 41 and up has a fixed version of binutils, and no longer requires that patch, but may fail without ld.gold installed; /usr/bin/gcc -Wl,-z,now -Wl,-z,nocopyreloc -fuse-ld=gold -o $WORK/b001/exe/a.out -rdynamic /tmp/go-link-1738353519/go.o /tmp/go-link-1738353519/000000.o /tmp/go-link-1738353519/000001.o /tmp/go-link-1738353519/000002.o /tmp/go-link-1738353519/000003.o /tmp/go-link-1738353519/000004.o /tmp/go-link-1738353519/000005.o /tmp/go-link-1738353519/000006.o /tmp/go-link-1738353519/000007.o /tmp/go-link-1738353519/000008.o /tmp/go-link-1738353519/000009.o /tmp/go-link-1738353519/000010.o /tmp/go-link-1738353519/000011.o /tmp/go-link-1738353519/000012.o /tmp/go-link-1738353519/000013.o /tmp/go-link-1738353519/000014.o /tmp/go-link-1738353519/000015.o /tmp/go-link-1738353519/000016.o /tmp/go-link-1738353519/000017.o /tmp/go-link-1738353519/000018.o /tmp/go-link-1738353519/000019.o /tmp/go-link-1738353519/000020.o /tmp/go-link-1738353519/000021.o /tmp/go-link-1738353519/000022.o /tmp/go-link-1738353519/000023.o /tmp/go-link-1738353519/000024.o -O2 -g -lresolv -O2 -g -lpthread -O2 -g -ldl -O2 -g collect2: fatal error: cannot find 'ld' Fedora's build of Go carries a patch for that, but it's not (yet) in upstream; - https://src.fedoraproject.org/rpms/golang/blob/a867bd88a656c1d6e91e7b18bab696dc3fcf1e77/f/0006-Default-to-ld.bfd-on-ARM64.patch - https://src.fedoraproject.org/rpms/golang/c/a867bd88a656c1d6e91e7b18bab696dc3fcf1e77?branch=rawhide Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This is the equivalent of docker/containerd-packaging#390 for containerd packages, but unlike for containerd packages, we currently do not run into this issue when building docker-ce packages. We're installing this as a precaution, but perhaps it's not needed. go1.21 and up have a patch that enforces the use of ld.gold to work around a bug in GNU binutils. See; - golang/go#22040. - golang/go@cd77738 Fedora 41 and up has a fixed version of binutils, and no longer requires that patch, but may fail without ld.gold installed; /usr/bin/gcc -Wl,-z,now -Wl,-z,nocopyreloc -fuse-ld=gold -o $WORK/b001/exe/a.out -rdynamic /tmp/go-link-1738353519/go.o /tmp/go-link-1738353519/000000.o /tmp/go-link-1738353519/000001.o /tmp/go-link-1738353519/000002.o /tmp/go-link-1738353519/000003.o /tmp/go-link-1738353519/000004.o /tmp/go-link-1738353519/000005.o /tmp/go-link-1738353519/000006.o /tmp/go-link-1738353519/000007.o /tmp/go-link-1738353519/000008.o /tmp/go-link-1738353519/000009.o /tmp/go-link-1738353519/000010.o /tmp/go-link-1738353519/000011.o /tmp/go-link-1738353519/000012.o /tmp/go-link-1738353519/000013.o /tmp/go-link-1738353519/000014.o /tmp/go-link-1738353519/000015.o /tmp/go-link-1738353519/000016.o /tmp/go-link-1738353519/000017.o /tmp/go-link-1738353519/000018.o /tmp/go-link-1738353519/000019.o /tmp/go-link-1738353519/000020.o /tmp/go-link-1738353519/000021.o /tmp/go-link-1738353519/000022.o /tmp/go-link-1738353519/000023.o /tmp/go-link-1738353519/000024.o -O2 -g -lresolv -O2 -g -lpthread -O2 -g -ldl -O2 -g collect2: fatal error: cannot find 'ld' Fedora's build of Go carries a patch for that, but it's not (yet) in upstream; - https://src.fedoraproject.org/rpms/golang/blob/a867bd88a656c1d6e91e7b18bab696dc3fcf1e77/f/0006-Default-to-ld.bfd-on-ARM64.patch - https://src.fedoraproject.org/rpms/golang/c/a867bd88a656c1d6e91e7b18bab696dc3fcf1e77?branch=rawhide Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit 563068b) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This is a workaround to a known issue with binutils and go >=v1.21 that currently requires ld.gold to be installed on arm64: https://sourceware.org/bugzilla/show_bug.cgi?id=19962 Fedora rawhide removes this requirement but the patch hasn't made it into a released version yet: https://src.fedoraproject.org/rpms/golang/blob/a867bd88a656c1d6e91e7b18bab696dc3fcf1e77/f/0006-Default-to-ld.bfd-on-ARM64.patch golang/go#22040 Signed-off-by: Lee Yarwood <lyarwood@redhat.com>
This is a workaround to a known issue with binutils and go >=v1.21 that currently requires ld.gold to be installed on arm64: https://sourceware.org/bugzilla/show_bug.cgi?id=19962 Fedora rawhide removes this requirement but the patch hasn't made it into a released version yet: https://src.fedoraproject.org/rpms/golang/blob/a867bd88a656c1d6e91e7b18bab696dc3fcf1e77/f/0006-Default-to-ld.bfd-on-ARM64.patch golang/go#22040 Signed-off-by: Lee Yarwood <lyarwood@redhat.com>
What version of Go are you using (
go version
)?Any, more specifically 1.8, 1.9, master, most probably all versions supporting AArch64/arm64 target
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?linux/arm64
What did you do?
GC on linux/arm64 assumes gold linker availability see
src/cmd/link/internal/ld/lib.go:1182
When gold is not available gcc fails due to it missing, when it tries to invoke it. All in shared_test.
When gold flag is remove by removing
sys.ARM64
from codition onsrc/cmd/link/internal/ld/lib.go:1173
, build/test fail withAnd so one for most of the cases shared_test.
What did you expect to see?
All tests pass. GC working with default binutils ld.
What did you see instead?
GC failing to build some binaries with binutils ld.
The text was updated successfully, but these errors were encountered: