Fix build without the gold linker
The Go runtime silently chose the gold linker on arm and aarch64 build targets to work around a binutils bug. That bug was from 2016, and has been fixed in binutils for a while. But the Go workaround was still in place. The workaround to choose gold was supposed to error out during the configure phase if gold wasn't found - but that doesn't happen. This leads to builds on aarch64 failing if attempting to compile without gold. Just removing the special condition in the Go source code: https://go-review.googlesource.com/c/go/+/391115/ works, but that patch is unlikely to be merged upstream. A patch fixing the build is more likely to be merged: https://go-review.googlesource.com/c/go/+/366279/ which updates the linker selection to use gold only if available. References to this bug in upstream Go and Binutils: https://github.com/golang/go/issues/22040 https://sourceware.org/bugzilla/show_bug.cgi?id=19962 Including the likely-to-be-merged patch here.
This commit is contained in:
parent
fd8ecd035f
commit
c874af597b
@ -0,0 +1,53 @@
|
|||||||
|
From 5ccf9f47bf4f5ba53e0ab7338a7fd4626714cfb2 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jeffery To <jeffery.to@gmail.com>
|
||||||
|
Date: Tue, 23 Nov 2021 15:05:37 +0800
|
||||||
|
Subject: [PATCH] cmd/link: use gold on ARM/ARM64 only if gold is available
|
||||||
|
|
||||||
|
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 #22040.
|
||||||
|
---
|
||||||
|
src/cmd/link/internal/ld/lib.go | 19 +++++++------------
|
||||||
|
1 file changed, 7 insertions(+), 12 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
|
||||||
|
index 9e13db7b71..2b379259a2 100644
|
||||||
|
--- a/src/cmd/link/internal/ld/lib.go
|
||||||
|
+++ b/src/cmd/link/internal/ld/lib.go
|
||||||
|
@@ -1390,25 +1390,20 @@ func (ctxt *Link) hostlink() {
|
||||||
|
}
|
||||||
|
|
||||||
|
if ctxt.Arch.InFamily(sys.ARM, sys.ARM64) && buildcfg.GOOS == "linux" {
|
||||||
|
- // On ARM, the GNU linker will generate COPY relocations
|
||||||
|
- // even with -znocopyreloc set.
|
||||||
|
+ // On ARM, older versions of the GNU linker will generate
|
||||||
|
+ // COPY relocations even with -znocopyreloc set.
|
||||||
|
// https://sourceware.org/bugzilla/show_bug.cgi?id=19962
|
||||||
|
//
|
||||||
|
- // On ARM64, the GNU linker will fail instead of
|
||||||
|
- // generating COPY relocations.
|
||||||
|
+ // On ARM64, older versions of the GNU linker will fail
|
||||||
|
+ // instead of generating COPY relocations.
|
||||||
|
//
|
||||||
|
- // In both cases, switch to gold.
|
||||||
|
- 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.
|
||||||
|
+ // In both cases, switch to gold if gold is available.
|
||||||
|
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("ARM external linker must be gold (issue #15696), but is not: %s", out)
|
||||||
|
+ if bytes.Contains(out, []byte("GNU gold")) {
|
||||||
|
+ altLinker = "gold"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.32.0
|
||||||
|
|
@ -114,7 +114,7 @@
|
|||||||
%global go_source %{go_api}%{?go_patch:.%{go_patch}}%{?go_prerelease}
|
%global go_source %{go_api}%{?go_patch:.%{go_patch}}%{?go_prerelease}
|
||||||
|
|
||||||
# For rpmdev-bumpspec and releng automation
|
# For rpmdev-bumpspec and releng automation
|
||||||
%global baserelease 1
|
%global baserelease 2
|
||||||
|
|
||||||
Name: golang
|
Name: golang
|
||||||
Version: %{go_version}
|
Version: %{go_version}
|
||||||
@ -162,6 +162,7 @@ Requires: %{name}-src = %{version}-%{release}
|
|||||||
|
|
||||||
Patch2: 0002-syscall-expose-IfInfomsg.X__ifi_pad-on-s390x.patch
|
Patch2: 0002-syscall-expose-IfInfomsg.X__ifi_pad-on-s390x.patch
|
||||||
Patch3: 0003-cmd-go-disable-Google-s-proxy-and-sumdb.patch
|
Patch3: 0003-cmd-go-disable-Google-s-proxy-and-sumdb.patch
|
||||||
|
Patch4: 0004-cmd-link-use-gold-on-ARM-ARM64-only-if-gold-is-avail.patch
|
||||||
|
|
||||||
# Having documentation separate was broken
|
# Having documentation separate was broken
|
||||||
Obsoletes: %{name}-docs < 1.1-4
|
Obsoletes: %{name}-docs < 1.1-4
|
||||||
@ -537,6 +538,9 @@ fi
|
|||||||
%endif
|
%endif
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Nov 8 2022 Amit Shah <amitshah@fedoraproject.org> - 1.19.3-2
|
||||||
|
- Fix build without binutils-gold
|
||||||
|
|
||||||
* Sun Nov 06 2022 Mike Rochefort <mroche@redhat.com> - 1.19.3-1
|
* Sun Nov 06 2022 Mike Rochefort <mroche@redhat.com> - 1.19.3-1
|
||||||
- Update to go1.19.3
|
- Update to go1.19.3
|
||||||
- Resolves: rhbz#2139548
|
- Resolves: rhbz#2139548
|
||||||
|
Loading…
Reference in New Issue
Block a user