Skip to content

Commit 506d6a3

Browse files
labogerbradfitz
authored andcommitted
cmd/go, cmd/link: provide meaningful error msg with ext linking on ppc64
linux/ppc64 uses the ppc64 v1 ABI which was never fully supported by Go. (linux/ppc64le uses the ppc64 v2 ABI and that is fully supported). As a result if the external linker is used to build a program on ppc64, there is a either a warning or error message that doesn't clearly describe the problem. In the case of a warning, a program is created that will most likely not execute since it is not built as expected for the ppc64 dynamic linker (ld64.so.1). To avoid confusion in these cases, error messages are now issued if external linker is explicitly used to build the program. Note that most buildmodes that require external linking were already flagging linux/ppc64 as unsupported except for c-archive, which has been added here. This problem does not occur with gccgo since the ppc64 v1 ABI is supported there. Fixes #25079 Change-Id: I44d77a1eb9df750d499cd432b0ca4a97f0be88b2 Reviewed-on: https://go-review.googlesource.com/109915 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 166c37a commit 506d6a3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/cmd/go/internal/work/init.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ func buildModeInit() {
8383
default:
8484
switch cfg.Goos {
8585
case "dragonfly", "freebsd", "linux", "netbsd", "openbsd", "solaris":
86+
if platform == "linux/ppc64" {
87+
base.Fatalf("-buildmode=c-archive not supported on %s\n", platform)
88+
}
8689
// Use -shared so that the result is
8790
// suitable for inclusion in a PIE or
8891
// shared library.

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ func determineLinkMode(ctxt *Link) {
240240
}
241241
ctxt.LinkMode = LinkInternal
242242
case "1":
243+
if objabi.GOARCH == "ppc64" {
244+
Exitf("external linking requested via GO_EXTLINK_ENABLED but not supported for linux/ppc64")
245+
}
243246
ctxt.LinkMode = LinkExternal
244247
default:
245248
if needed, _ := mustLinkExternal(ctxt); needed {
@@ -251,10 +254,17 @@ func determineLinkMode(ctxt *Link) {
251254
} else {
252255
ctxt.LinkMode = LinkInternal
253256
}
257+
if objabi.GOARCH == "ppc64" && ctxt.LinkMode == LinkExternal {
258+
Exitf("external linking is not supported for linux/ppc64")
259+
}
254260
}
255261
case LinkInternal:
256262
if needed, reason := mustLinkExternal(ctxt); needed {
257263
Exitf("internal linking requested but external linking required: %s", reason)
258264
}
265+
case LinkExternal:
266+
if objabi.GOARCH == "ppc64" {
267+
Exitf("external linking not supported for linux/ppc64")
268+
}
259269
}
260270
}

0 commit comments

Comments
 (0)