Jeff Kowalczyk changed bug 1170826
What Removed Added
Flags needinfo?(jkowalczyk@suse.com), needinfo?(guillaume.gardet@arm.com)  

Comment # 15 on bug 1170826 from
It does seem that go1.x on ARM depends on the gold linker for stated reasons of
GNU linker behavior with COPY relocations. The error "collect2: fatal error:
cannot find 'ld'" likely results from the flag "-fuse-ld=gold" being
automatically applied:

go1.14 $ grep gold -B 19 -A 3 src/cmd/link/internal/ld/lib.go
if ctxt.IsELF && ctxt.DynlinkingGo() {
    // We force all symbol resolution to be done at program startup
    // because lazy PLT resolution can use large amounts of stack at
    // times we cannot allow it to do so.
    argv = append(argv, "-Wl,-znow")

    // Do not let the host linker generate COPY relocations. These
    // can move symbols out of sections that rely on stable offsets
    // from the beginning of the section (like sym.STYPE).
    argv = append(argv, "-Wl,-znocopyreloc")

    if ctxt.Arch.InFamily(sys.ARM, sys.ARM64) && objabi.GOOS == "linux" {
        // On ARM, 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.
        //
        // In both cases, switch to gold.
        argv = append(argv, "-fuse-ld=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.
        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)
            }
        }
    }

https://github.com/golang/go/blob/release-branch.go1.14/src/cmd/link/internal/ld/lib.go#L1305


Notably, Android was removed in late 2019 from the platforms where
"-fuse-ld=gold" is automatically applied:

https://github.com/golang/go/commit/d3c2b1f17600fadeebf62d65c85baf3bef879e2b
"The NDK is switching to ldd, and will stop including the gold linker."



There is active development on the internal Go linker, which may influence what
degree of accommodations should be made for gold:

https://golang.org/doc/go1.15#linker  (go1.15 was released 2020-08-11)

"... This release includes substantial improvements to the Go linker, which
reduce linker resource usage (both time and memory) and improve code
robustness/maintainability.

For a representative set of large Go programs, linking is 20% faster and
requires 30% less memory on average, for ELF-based OSes (Linux, FreeBSD,
NetBSD, OpenBSD, Dragonfly, and Solaris) running on amd64 architectures, with
more modest improvements for other architecture/OS combinations.

The key contributors to better linker performance are a newly redesigned object
file format, and a revamping of internal phases to increase concurrency (for
example, applying relocations to symbols in parallel). Object files in Go 1.15
are slightly larger than their 1.14 equivalents.

These changes are part of a multi-release project to modernize the Go linker,
meaning that there will be additional linker improvements expected in future
releases.

The linker now defaults to internal linking mode for -buildmode=pie on
linux/amd64 and linux/arm64, so these configurations no longer require a C
linker. External linking mode (which was the default in Go 1.14 for
-buildmode=pie) can still be requested with -ldflags=-linkmode=external flag.



Building a better Go linker (2019)
https://golang.org/s/better-linker


You are receiving this mail because: