Commit ab7e82ef authored by David Crawshaw's avatar David Crawshaw

cmd/go: buildmode=c-shared support for linux/arm64

Change-Id: Ic826dc25b5203b2e9fc253d6fe997e4b41de3789
Reviewed-on: https://go-review.googlesource.com/16453Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 3356624d
// 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)
}
// 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)
}
......@@ -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)
}
......
......@@ -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
......
......@@ -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' {
......
......@@ -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
......
......@@ -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":
......
......@@ -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)
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment