openwrt-packages/lang/golang/golang/patches/001-cmd-link-use-gold-on-AR...

36 lines
1.4 KiB
Diff

This is https://github.com/golang/go/pull/49748 backported for Go 1.17.
--- a/src/cmd/link/internal/ld/lib.go
+++ b/src/cmd/link/internal/ld/lib.go
@@ -1391,23 +1391,18 @@ 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.
cmd := exec.Command(*flagExtld, "-fuse-ld=gold", "-Wl,--version")
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"
}
}
}