]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go, cmd/link: provide meaningful error msg with ext linking on ppc64
authorLynn Boger <laboger@linux.vnet.ibm.com>
Fri, 27 Apr 2018 12:07:48 +0000 (08:07 -0400)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 4 May 2018 15:05:41 +0000 (15:05 +0000)
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 <bradfitz@golang.org>
src/cmd/go/internal/work/init.go
src/cmd/link/internal/ld/config.go

index 3eb98381bd6e4ba6aab5e3120791d4eda5362d01..4d3c5cbd17a01c4a069af4b9dab3366f5c77c716 100644 (file)
@@ -83,6 +83,9 @@ func buildModeInit() {
                default:
                        switch cfg.Goos {
                        case "dragonfly", "freebsd", "linux", "netbsd", "openbsd", "solaris":
+                               if platform == "linux/ppc64" {
+                                       base.Fatalf("-buildmode=c-archive not supported on %s\n", platform)
+                               }
                                // Use -shared so that the result is
                                // suitable for inclusion in a PIE or
                                // shared library.
index a20dfd3f324e58b0cc787e9785475fd2be6bdb18..6685ad50ac052915c951537f90ce85932336079b 100644 (file)
@@ -240,6 +240,9 @@ func determineLinkMode(ctxt *Link) {
                        }
                        ctxt.LinkMode = LinkInternal
                case "1":
+                       if objabi.GOARCH == "ppc64" {
+                               Exitf("external linking requested via GO_EXTLINK_ENABLED but not supported for linux/ppc64")
+                       }
                        ctxt.LinkMode = LinkExternal
                default:
                        if needed, _ := mustLinkExternal(ctxt); needed {
@@ -251,10 +254,17 @@ func determineLinkMode(ctxt *Link) {
                        } else {
                                ctxt.LinkMode = LinkInternal
                        }
+                       if objabi.GOARCH == "ppc64" && ctxt.LinkMode == LinkExternal {
+                               Exitf("external linking is not supported for linux/ppc64")
+                       }
                }
        case LinkInternal:
                if needed, reason := mustLinkExternal(ctxt); needed {
                        Exitf("internal linking requested but external linking required: %s", reason)
                }
+       case LinkExternal:
+               if objabi.GOARCH == "ppc64" {
+                       Exitf("external linking not supported for linux/ppc64")
+               }
        }
 }