golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.35k stars 17.71k forks source link

cmd/link: linker should fail quickly when external link mode is not supported #34373

Open jeremyfaller opened 5 years ago

jeremyfaller commented 5 years ago

What version of Go are you using (go version)?

HEAD

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
darwin, 386

What did you do?

While investigating Issue 33808 I discovered that external linking doesn't work in 32bit darwin.

What did you expect to see?

Linker should fail quickly when trying to do an external link.

What did you see instead?

Linker calls external linker, external linker fails.

CC @cherrymui

laboger commented 5 years ago

External linking is supported on ppc64le, but not on ppc64. If we try to link externally we see this:

go build -ldflags '-linkmode=external' hello.go
# command-line-arguments
/home/boger/golang/base/go/pkg/tool/linux_ppc64/link: external linking not supported for linux/ppc64
jeremyfaller commented 5 years ago

Thanks, @laboger. The problem was discovered with darwin/32-bit (which for recent versions of darwin don't support external linking), and was filed as a generic bug. Thanks for checking PPC.

toshywoshy commented 3 years ago

Not sure if this helps, but I have it working with CGO_ENABLED=1

CGO_ENABLED=1 go build -ldflags '-linkmode=external' hello.go

This compiles and works for my compiled version of Golang on ppc64 BE as described in the links here below Source link https://git.powerel.org/powerel7/base/src/branch/master/SPECS/golang.spec https://git.powerel.org/powerel7/base/src/branch/master/SOURCES/golang-1.16-ppc64-linker.patch Binary link https://mirror0.powerel.org/pel/7/power8/ppc64/base/packages/golang-1.16.5-1.pel7.ppc64.rpm These are for PowerEL 7 ppc64 on IBM POWER8