]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: add missing gccgo checks for buildmodeInit
authorLynn Boger <laboger@linux.vnet.ibm.com>
Mon, 3 Dec 2018 22:02:20 +0000 (17:02 -0500)
committerLynn Boger <laboger@linux.vnet.ibm.com>
Tue, 4 Dec 2018 13:45:21 +0000 (13:45 +0000)
Some recent failures in gccgo on linux/ppc64 identified
an error in buildmodeInit when buildmode=c-archive.
A fix went into gofrontend, and this is the
corresponding change for master. This change also includes
two other updates related to gccgo in this function that
were in the file from gofrontend but missing from master.

Updates #29046

Change-Id: I9a894e7d728e31fb9e9344cd61d50408df7faf4a
Reviewed-on: https://go-review.googlesource.com/c/152160
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/go/internal/work/init.go

index 8d2fd10524b06f58b44d807e05200fdf2393c595..693a53e9ab78d012f493bb619f5471f6c2d1f9ed 100644 (file)
@@ -82,19 +82,23 @@ func buildModeInit() {
                pkgsFilter = pkgsNotMain
        case "c-archive":
                pkgsFilter = oneMainPkg
-               switch platform {
-               case "darwin/arm", "darwin/arm64":
-                       codegenArg = "-shared"
-               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.
+               if gccgo {
+                       codegenArg = "-fPIC"
+               } else {
+                       switch platform {
+                       case "darwin/arm", "darwin/arm64":
                                codegenArg = "-shared"
+                       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.
+                                       codegenArg = "-shared"
+                               }
                        }
                }
                cfg.ExeSuffix = ".a"
@@ -129,6 +133,9 @@ func buildModeInit() {
                default:
                        ldBuildmode = "exe"
                }
+               if gccgo {
+                       codegenArg = ""
+               }
        case "exe":
                pkgsFilter = pkgsMain
                ldBuildmode = "exe"
@@ -143,7 +150,7 @@ func buildModeInit() {
                        base.Fatalf("-buildmode=pie not supported when -race is enabled")
                }
                if gccgo {
-                       base.Fatalf("-buildmode=pie not supported by gccgo")
+                       codegenArg = "-fPIE"
                } else {
                        switch platform {
                        case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/s390x",