--- /dev/null
+// 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)
+}
--- /dev/null
+// 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)
+}
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)
}
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
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' {
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
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":
break
}
+ if ld.Buildmode == ld.BuildmodeCShared {
+ ld.Linkmode = ld.LinkExternal
+ }
+
switch ld.HEADTYPE {
default:
ld.Exitf("unknown -H option: %v", ld.HEADTYPE)
}
*mode = BuildmodeCArchive
case "c-shared":
- if goarch != "amd64" && goarch != "arm" {
+ if goarch != "amd64" && goarch != "arm" && goarch != "arm64" {
return badmode()
}
*mode = BuildmodeCShared