From cd77738198ffe0c4a1db58352c89f9b2d2a4e85e Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 15 Feb 2023 14:05:22 -0800 Subject: [PATCH] cmd/link: don't switch to gold on ARM Linux The bug in GNU ld appears to have been fixed in GNU binutils 2.28 by GNU binutils revision 5522f910cb539905d6adfdceab208ddfa5e84557. (This may have been accidental as the ChangeLog for the fix makes no reference to it; the fix is from https://sourceware.org/bugzilla/show_bug.cgi?id=19962). Continue using gold on arm64, at least for now, because as reported in issue #22040 GNU ld still fails there. For #15696 For #22040 Change-Id: I5534bb8b5680daf536a7941aba5c701e8a4138ab Reviewed-on: https://go-review.googlesource.com/c/go/+/468655 Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot Auto-Submit: Ian Lance Taylor Reviewed-by: Than McIntosh Run-TryBot: Ian Lance Taylor --- src/cmd/link/internal/ld/lib.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index baca7cd65f9589..d96f1322564276 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -1551,15 +1551,12 @@ func (ctxt *Link) hostlink() { altLinker = "lld" } - if ctxt.Arch.InFamily(sys.ARM, sys.ARM64) && buildcfg.GOOS == "linux" { - // On ARM, the GNU linker will generate COPY relocations - // even with -znocopyreloc set. + 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 - // - // On ARM64, the GNU linker will fail instead of - // generating COPY relocations. - // - // In both cases, switch to gold. + // https://go.dev/issue/22040 altLinker = "gold" // If gold is not installed, gcc will silently switch @@ -1570,7 +1567,7 @@ func (ctxt *Link) hostlink() { 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) + log.Fatalf("ARM64 external linker must be gold (issue #15696, 22040), but is not: %s", out) } } }