]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: buildmode=c-shared support for linux/arm64
authorDavid Crawshaw <crawshaw@golang.org>
Wed, 28 Oct 2015 21:57:30 +0000 (17:57 -0400)
committerDavid Crawshaw <crawshaw@golang.org>
Thu, 29 Oct 2015 16:25:37 +0000 (16:25 +0000)
Change-Id: Ic826dc25b5203b2e9fc253d6fe997e4b41de3789
Reviewed-on: https://go-review.googlesource.com/16453
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

misc/cgo/testcshared/src/libgo2/dup2.go [new file with mode: 0644]
misc/cgo/testcshared/src/libgo2/dup3.go [new file with mode: 0644]
misc/cgo/testcshared/src/libgo2/libgo2.go
misc/cgo/testcshared/test.bash
src/cmd/compile/internal/gc/lex.go
src/cmd/dist/test.go
src/cmd/go/build.go
src/cmd/link/internal/arm64/obj.go
src/cmd/link/internal/ld/lib.go

diff --git a/misc/cgo/testcshared/src/libgo2/dup2.go b/misc/cgo/testcshared/src/libgo2/dup2.go
new file mode 100644 (file)
index 0000000..d18f0b1
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2015 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.
+
+// +build darwin dragonfly freebsd linux,!arm64 netbsd openbsd
+
+package main
+
+import "syscall"
+
+func dup2(oldfd, newfd int) error {
+       return syscall.Dup2(oldfd, newfd)
+}
diff --git a/misc/cgo/testcshared/src/libgo2/dup3.go b/misc/cgo/testcshared/src/libgo2/dup3.go
new file mode 100644 (file)
index 0000000..c9c65a6
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2015 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.
+
+// +build linux,arm64
+
+package main
+
+import "syscall"
+
+func dup2(oldfd, newfd int) error {
+       return syscall.Dup3(oldfd, newfd, 0)
+}
index 6096860d637986f2dc654697841a344416526e96..636679b978cdccff1167af82473ad1ede9a0c13b 100644 (file)
@@ -31,7 +31,7 @@ func init() {
                os.Exit(2)
        }
 
-       if e := syscall.Dup2(p[0], fd); e != nil {
+       if e := dup2(p[0], fd); e != nil {
                fmt.Fprintf(os.Stderr, "dup2: %v\n", e)
                os.Exit(2)
        }
index 1b9f919d00f24219b994d784502aaa5caac8ef3c..a6411628a7830a93fb271b2e2e033171fe166c86 100755 (executable)
@@ -114,7 +114,7 @@ if [ "$output" != "PASS" ]; then
 fi
 
 # test2: tests libgo2 which does not export any functions.
-GOPATH=$(pwd) go build -buildmode=c-shared $suffix -o libgo2.$libext src/libgo2/libgo2.go
+GOPATH=$(pwd) go build -buildmode=c-shared $suffix -o libgo2.$libext libgo2
 binpush libgo2.$libext
 linkflags="-Wl,--no-as-needed"
 if [ "$goos" == "darwin" ]; then
index 334b3ea715e026e651c4e8c8d986caf8bab76a68..b6a43ac49ef6ae05bf67520bf5fa99c52eb756cf 100644 (file)
@@ -220,7 +220,8 @@ func Main() {
        obj.Flagcount("y", "debug declarations in canned imports (with -d)", &Debug['y'])
        var flag_shared int
        var flag_dynlink bool
-       if Thearch.Thechar == '5' || Thearch.Thechar == '6' || Thearch.Thechar == '9' {
+       switch Thearch.Thechar {
+       case '5', '6', '7', '9':
                obj.Flagcount("shared", "generate code that can be linked into a shared library", &flag_shared)
        }
        if Thearch.Thechar == '6' {
index 0afe4c6060452505820357fdf1dc0835ee8f25ad..6b0056a3ae8df1f1695bd316f7e9cd0b39860c74 100644 (file)
@@ -581,7 +581,7 @@ func (t *tester) supportedBuildmode(mode string) bool {
        case "c-shared":
                // TODO(hyangah): add linux-386.
                switch pair {
-               case "linux-amd64", "darwin-amd64", "android-arm", "linux-arm":
+               case "linux-amd64", "darwin-amd64", "android-arm", "linux-arm", "linux-arm64":
                        return true
                }
                return false
index c87cedc571dda552a671a69462cfd79a96de5de8..e25a56ac301e9100d031ac2cc6cce09341122553 100644 (file)
@@ -350,7 +350,7 @@ func buildModeInit() {
                        codegenArg = "-fPIC"
                } else {
                        switch platform {
-                       case "linux/amd64", "linux/arm",
+                       case "linux/amd64", "linux/arm", "linux/arm64",
                                "android/amd64", "android/arm":
                                codegenArg = "-shared"
                        case "darwin/amd64":
index 56f581590339fb88cc41d9fcc12d67b0709ee0fc..5c28551d65ee3836dc8f6ff7b9edfa3a4b76458f 100644 (file)
@@ -104,6 +104,10 @@ func archinit() {
                break
        }
 
+       if ld.Buildmode == ld.BuildmodeCShared {
+               ld.Linkmode = ld.LinkExternal
+       }
+
        switch ld.HEADTYPE {
        default:
                ld.Exitf("unknown -H option: %v", ld.HEADTYPE)
index b97cf0fe58f251e02a2715919d5a3fa6f998c76f..ff9cabc21435ba447f0fe38e2353f7803c943d42 100644 (file)
@@ -316,7 +316,7 @@ func (mode *BuildMode) Set(s string) error {
                }
                *mode = BuildmodeCArchive
        case "c-shared":
-               if goarch != "amd64" && goarch != "arm" {
+               if goarch != "amd64" && goarch != "arm" && goarch != "arm64" {
                        return badmode()
                }
                *mode = BuildmodeCShared