]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: don't switch to gold on ARM Linux
authorIan Lance Taylor <iant@golang.org>
Wed, 15 Feb 2023 22:05:22 +0000 (14:05 -0800)
committerGopher Robot <gobot@golang.org>
Thu, 16 Feb 2023 23:57:39 +0000 (23:57 +0000)
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 <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

src/cmd/link/internal/ld/lib.go

index baca7cd65f95895fb097770580ee7e0259053abd..d96f13225642766e9bbebc3ae589d897e5b60fa4 100644 (file)
@@ -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)
                                }
                        }
                }