]> Cypherpunks repositories - gostls13.git/commitdiff
all: add GOOS=ios GOARCH=amd64 target for the ios simulator
authorElias Naur <mail@eliasnaur.com>
Tue, 20 Oct 2020 09:01:46 +0000 (11:01 +0200)
committerElias Naur <mail@eliasnaur.com>
Thu, 22 Oct 2020 17:13:24 +0000 (17:13 +0000)
The Go toolchain has supported the simulator for years, but always in
buildmode=c-archive which is intrinsically externally linked and PIE.

This CL moves that support from GOOS=darwin GOARCH=amd64 -tags=ios to
just GOOS=ios GOARCH=amd64 to match the change for iOS devices.

This change also forces external linking and defaults to buildmode=pie
to support Go binaries in the default buildmode to run on the simulator.

CL 255257 added the necessary support to the exec wrapper.

Updates #38485
Fixes #42100

Change-Id: I6e6ee0e8d421be53b31e3d403880e5b9b880d031
Reviewed-on: https://go-review.googlesource.com/c/go/+/263798
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Elias Naur <mail@eliasnaur.com>

src/cmd/dist/build.go
src/cmd/go/internal/load/pkg.go
src/cmd/go/internal/work/init.go
src/cmd/internal/sys/supported.go
src/cmd/link/internal/ld/config.go
src/runtime/rt0_ios_amd64.s [new file with mode: 0644]

index d902addb0c1b9264f4485fc2db8c9f779503b5b1..e46c33522d79fda1d21927e606da39f4ca9bf19f 100644 (file)
@@ -1557,6 +1557,7 @@ var cgoEnabled = map[string]bool{
        "android/arm":     true,
        "android/arm64":   true,
        "ios/arm64":       true,
+       "ios/amd64":       true,
        "js/wasm":         false,
        "netbsd/386":      true,
        "netbsd/amd64":    true,
index f07bd3e075ef959711de2c89c77a67654fba276b..29709a6dd37d09e0deb61ca51202029fa09a33d9 100644 (file)
@@ -1966,7 +1966,9 @@ func externalLinkingForced(p *Package) bool {
                if cfg.BuildContext.GOARCH != "arm64" {
                        return true
                }
-       case "darwin", "ios":
+       case "ios":
+               return true
+       case "darwin":
                if cfg.BuildContext.GOARCH == "arm64" {
                        return true
                }
index 81c4fb746571b299d40823190bfe8f39535bf114..d65c076c6a82a6c04de190c06865538bbf054d79 100644 (file)
@@ -168,7 +168,10 @@ func buildModeInit() {
                        ldBuildmode = "pie"
                case "windows":
                        ldBuildmode = "pie"
-               case "darwin", "ios":
+               case "ios":
+                       codegenArg = "-shared"
+                       ldBuildmode = "pie"
+               case "darwin":
                        switch cfg.Goarch {
                        case "arm64":
                                codegenArg = "-shared"
index c433a872bed27d23f80fd22109c655f6f366f997..ccc5b2245b60210299d33577203456664aeffa09 100644 (file)
@@ -88,6 +88,7 @@ func BuildModeSupported(compiler, buildmode, goos, goarch string) bool {
                        "android/amd64", "android/arm", "android/arm64", "android/386",
                        "freebsd/amd64",
                        "darwin/amd64", "darwin/arm64",
+                       "ios/amd64", "ios/arm64",
                        "aix/ppc64",
                        "windows/386", "windows/amd64", "windows/arm":
                        return true
index a54b96dd5d76d523c929cf16a32ee7d8867f7536..54a94cebbafd24e45c510decf360208b2d353e7f 100644 (file)
@@ -42,13 +42,7 @@ func (mode *BuildMode) Set(s string) error {
                *mode = BuildModeExe
        case "pie":
                switch objabi.GOOS {
-               case "aix", "android", "linux", "windows":
-               case "darwin":
-                       switch objabi.GOARCH {
-                       case "amd64", "arm64":
-                       default:
-                               return badmode()
-                       }
+               case "aix", "android", "linux", "windows", "darwin", "ios":
                case "freebsd":
                        switch objabi.GOARCH {
                        case "amd64":
diff --git a/src/runtime/rt0_ios_amd64.s b/src/runtime/rt0_ios_amd64.s
new file mode 100644 (file)
index 0000000..c699032
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#include "textflag.h"
+
+// internal linking executable entry point.
+// ios/amd64 only supports external linking.
+TEXT _rt0_amd64_ios(SB),NOSPLIT|NOFRAME,$0
+       UNDEF
+
+// library entry point.
+TEXT _rt0_amd64_ios_lib(SB),NOSPLIT|NOFRAME,$0
+       JMP     _rt0_amd64_darwin_lib(SB)