Skip to content

Commit

Permalink
cmd/link: don't switch to gold on ARM Linux
Browse files Browse the repository at this point in the history
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 <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Auto-Submit: Ian Lance Taylor <[email protected]>
Reviewed-by: Than McIntosh <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
  • Loading branch information
ianlancetaylor authored and gopherbot committed Feb 16, 2023
1 parent 3ad6393 commit cd77738
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/cmd/link/internal/ld/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
}
}
Expand Down

0 comments on commit cd77738

Please sign in to comment.