mirror of
https://github.com/golang/go
synced 2024-11-23 07:50:05 -07:00
cmd/go: buildmode=c-shared support for linux/arm64
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>
This commit is contained in:
parent
3356624df3
commit
ab7e82ef3b
13
misc/cgo/testcshared/src/libgo2/dup2.go
Normal file
13
misc/cgo/testcshared/src/libgo2/dup2.go
Normal file
@ -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)
|
||||
}
|
13
misc/cgo/testcshared/src/libgo2/dup3.go
Normal file
13
misc/cgo/testcshared/src/libgo2/dup3.go
Normal file
@ -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)
|
||||
}
|
@ -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' {
|
||||
|
2
src/cmd/dist/test.go
vendored
2
src/cmd/dist/test.go
vendored
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user