aboutsummaryrefslogtreecommitdiff
path: root/libgo/misc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2020-07-27 22:27:54 -0700
committerIan Lance Taylor <iant@golang.org>2020-08-01 11:21:40 -0700
commitf75af8c1464e948b5e166cf5ab09ebf0d82fc253 (patch)
tree3ba3299859b504bdeb477727471216bd094a0191 /libgo/misc
parent75a23e59031fe673fc3b2e60fd1fe5f4c70ecb85 (diff)
downloadgcc-f75af8c1464e948b5e166cf5ab09ebf0d82fc253.zip
gcc-f75af8c1464e948b5e166cf5ab09ebf0d82fc253.tar.gz
gcc-f75af8c1464e948b5e166cf5ab09ebf0d82fc253.tar.bz2
libgo: update to go1.15rc1
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/245157
Diffstat (limited to 'libgo/misc')
-rw-r--r--libgo/misc/cgo/test/pkg_test.go2
-rw-r--r--libgo/misc/cgo/test/sigaltstack.go15
-rw-r--r--libgo/misc/cgo/test/test.go12
-rw-r--r--libgo/misc/cgo/test/testdata/issue27054/egl.h1
-rw-r--r--libgo/misc/cgo/test/testdata/issue27054/test27054.go6
-rw-r--r--libgo/misc/cgo/test/testx.go2
-rw-r--r--libgo/misc/cgo/testcarchive/carchive_test.go8
-rw-r--r--libgo/misc/cgo/testcshared/cshared_test.go2
-rw-r--r--libgo/misc/cgo/testgodefs/testdata/issue38649.go15
-rw-r--r--libgo/misc/cgo/testgodefs/testdata/issue39534.go12
-rw-r--r--libgo/misc/cgo/testgodefs/testdata/main.go3
-rw-r--r--libgo/misc/cgo/testgodefs/testgodefs_test.go2
-rw-r--r--libgo/misc/cgo/testplugin/plugin_test.go2
-rw-r--r--libgo/misc/cgo/testshared/shared_test.go30
-rw-r--r--libgo/misc/cgo/testshared/testdata/gcdata/main/main.go37
-rw-r--r--libgo/misc/cgo/testshared/testdata/gcdata/p/p.go7
-rw-r--r--libgo/misc/cgo/testshared/testdata/issue39777/a/a.go9
-rw-r--r--libgo/misc/cgo/testshared/testdata/issue39777/b/b.go7
-rw-r--r--libgo/misc/cgo/testso/so_test.go6
-rw-r--r--libgo/misc/cgo/testsovar/so_test.go6
20 files changed, 157 insertions, 27 deletions
diff --git a/libgo/misc/cgo/test/pkg_test.go b/libgo/misc/cgo/test/pkg_test.go
index 08e075c..26c50ad 100644
--- a/libgo/misc/cgo/test/pkg_test.go
+++ b/libgo/misc/cgo/test/pkg_test.go
@@ -32,7 +32,7 @@ func TestCrossPackageTests(t *testing.T) {
t.Skip("Can't exec cmd/go subprocess on Android.")
case "darwin":
switch runtime.GOARCH {
- case "arm", "arm64":
+ case "arm64":
t.Skip("Can't exec cmd/go subprocess on iOS.")
}
}
diff --git a/libgo/misc/cgo/test/sigaltstack.go b/libgo/misc/cgo/test/sigaltstack.go
index 2c9b81c..8dfa1cb 100644
--- a/libgo/misc/cgo/test/sigaltstack.go
+++ b/libgo/misc/cgo/test/sigaltstack.go
@@ -14,15 +14,22 @@ package cgotest
#include <stdlib.h>
#include <string.h>
+#ifdef _AIX
+// On AIX, SIGSTKSZ is too small to handle Go sighandler.
+#define CSIGSTKSZ 0x4000
+#else
+#define CSIGSTKSZ SIGSTKSZ
+#endif
+
static stack_t oss;
-static char signalStack[SIGSTKSZ];
+static char signalStack[CSIGSTKSZ];
static void changeSignalStack(void) {
stack_t ss;
memset(&ss, 0, sizeof ss);
ss.ss_sp = signalStack;
ss.ss_flags = 0;
- ss.ss_size = SIGSTKSZ;
+ ss.ss_size = CSIGSTKSZ;
if (sigaltstack(&ss, &oss) < 0) {
perror("sigaltstack");
abort();
@@ -55,10 +62,8 @@ import (
func testSigaltstack(t *testing.T) {
switch {
- case runtime.GOOS == "solaris", runtime.GOOS == "illumos", runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64"):
+ case runtime.GOOS == "solaris", runtime.GOOS == "illumos", runtime.GOOS == "darwin" && runtime.GOARCH == "arm64":
t.Skipf("switching signal stack not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
- case runtime.GOOS == "darwin" && runtime.GOARCH == "386":
- t.Skipf("sigaltstack fails on darwin/386")
}
C.changeSignalStack()
diff --git a/libgo/misc/cgo/test/test.go b/libgo/misc/cgo/test/test.go
index b014899..8c69ad9 100644
--- a/libgo/misc/cgo/test/test.go
+++ b/libgo/misc/cgo/test/test.go
@@ -897,6 +897,10 @@ static uint16_t issue31093F(uint16_t v) { return v; }
// issue 32579
typedef struct S32579 { unsigned char data[1]; } S32579;
+
+// issue 38649
+// Test that #define'd type aliases work.
+#define netbsd_gid unsigned int
*/
import "C"
@@ -2192,3 +2196,11 @@ func test32579(t *testing.T) {
t.Errorf("&s[0].data[0] failed: got %d, want %d", s[0].data[0], 1)
}
}
+
+// issue 38649
+
+var issue38649 C.netbsd_gid = 42
+
+// issue 39877
+
+var issue39877 *C.void = nil
diff --git a/libgo/misc/cgo/test/testdata/issue27054/egl.h b/libgo/misc/cgo/test/testdata/issue27054/egl.h
index 33a759e..3079627 100644
--- a/libgo/misc/cgo/test/testdata/issue27054/egl.h
+++ b/libgo/misc/cgo/test/testdata/issue27054/egl.h
@@ -5,3 +5,4 @@
// This is the relevant part of EGL/egl.h.
typedef void *EGLDisplay;
+typedef void *EGLConfig;
diff --git a/libgo/misc/cgo/test/testdata/issue27054/test27054.go b/libgo/misc/cgo/test/testdata/issue27054/test27054.go
index 186f5bd..01bf43a 100644
--- a/libgo/misc/cgo/test/testdata/issue27054/test27054.go
+++ b/libgo/misc/cgo/test/testdata/issue27054/test27054.go
@@ -13,5 +13,9 @@ import (
)
func Test27054(t *testing.T) {
- var _ C.EGLDisplay = 0 // Note: 0, not nil. That makes sure we use uintptr for this type.
+ var (
+ // Note: 0, not nil. That makes sure we use uintptr for these types.
+ _ C.EGLDisplay = 0
+ _ C.EGLConfig = 0
+ )
}
diff --git a/libgo/misc/cgo/test/testx.go b/libgo/misc/cgo/test/testx.go
index eb9d7fa..7fbc5c6 100644
--- a/libgo/misc/cgo/test/testx.go
+++ b/libgo/misc/cgo/test/testx.go
@@ -164,7 +164,7 @@ func Add(x int) {
}
func testCthread(t *testing.T) {
- if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") {
+ if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" {
t.Skip("the iOS exec wrapper is unable to properly handle the panic from Add")
}
sum.i = 0
diff --git a/libgo/misc/cgo/testcarchive/carchive_test.go b/libgo/misc/cgo/testcarchive/carchive_test.go
index 98cd41a..af50e1e 100644
--- a/libgo/misc/cgo/testcarchive/carchive_test.go
+++ b/libgo/misc/cgo/testcarchive/carchive_test.go
@@ -134,7 +134,7 @@ func testMain(m *testing.M) int {
} else {
switch GOOS {
case "darwin":
- if GOARCH == "arm" || GOARCH == "arm64" {
+ if GOARCH == "arm64" {
libbase += "_shared"
}
case "dragonfly", "freebsd", "linux", "netbsd", "openbsd", "solaris", "illumos":
@@ -305,7 +305,7 @@ func TestEarlySignalHandler(t *testing.T) {
switch GOOS {
case "darwin":
switch GOARCH {
- case "arm", "arm64":
+ case "arm64":
t.Skipf("skipping on %s/%s; see https://golang.org/issue/13701", GOOS, GOARCH)
}
case "windows":
@@ -487,7 +487,7 @@ func checkSignalForwardingTest(t *testing.T) {
switch GOOS {
case "darwin":
switch GOARCH {
- case "arm", "arm64":
+ case "arm64":
t.Skipf("skipping on %s/%s; see https://golang.org/issue/13701", GOOS, GOARCH)
}
case "windows":
@@ -603,7 +603,7 @@ func TestExtar(t *testing.T) {
if runtime.Compiler == "gccgo" {
t.Skip("skipping -extar test when using gccgo")
}
- if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") {
+ if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" {
t.Skip("shell scripts are not executable on iOS hosts")
}
diff --git a/libgo/misc/cgo/testcshared/cshared_test.go b/libgo/misc/cgo/testcshared/cshared_test.go
index cb95153..bd4d341 100644
--- a/libgo/misc/cgo/testcshared/cshared_test.go
+++ b/libgo/misc/cgo/testcshared/cshared_test.go
@@ -108,7 +108,7 @@ func testMain(m *testing.M) int {
libgodir := GOOS + "_" + GOARCH
switch GOOS {
case "darwin":
- if GOARCH == "arm" || GOARCH == "arm64" {
+ if GOARCH == "arm64" {
libgodir += "_shared"
}
case "dragonfly", "freebsd", "linux", "netbsd", "openbsd", "solaris", "illumos":
diff --git a/libgo/misc/cgo/testgodefs/testdata/issue38649.go b/libgo/misc/cgo/testgodefs/testdata/issue38649.go
new file mode 100644
index 0000000..6af74d6
--- /dev/null
+++ b/libgo/misc/cgo/testgodefs/testdata/issue38649.go
@@ -0,0 +1,15 @@
+// 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.
+//
+// +build ignore
+
+package main
+
+/*
+struct Issue38649 { int x; };
+#define issue38649 struct Issue38649
+*/
+import "C"
+
+type issue38649 C.issue38649
diff --git a/libgo/misc/cgo/testgodefs/testdata/issue39534.go b/libgo/misc/cgo/testgodefs/testdata/issue39534.go
new file mode 100644
index 0000000..9899ba1
--- /dev/null
+++ b/libgo/misc/cgo/testgodefs/testdata/issue39534.go
@@ -0,0 +1,12 @@
+// 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.
+//
+// +build ignore
+
+package main
+
+// enum { ENUMVAL = 0x1 };
+import "C"
+
+const ENUMVAL = C.ENUMVAL
diff --git a/libgo/misc/cgo/testgodefs/testdata/main.go b/libgo/misc/cgo/testgodefs/testdata/main.go
index ef45b95..2e1ad33 100644
--- a/libgo/misc/cgo/testgodefs/testdata/main.go
+++ b/libgo/misc/cgo/testgodefs/testdata/main.go
@@ -19,5 +19,8 @@ var v6 = B{}
// Test that S is fully defined
var v7 = S{}
+// Test that #define'd type is fully defined
+var _ = issue38649{X: 0}
+
func main() {
}
diff --git a/libgo/misc/cgo/testgodefs/testgodefs_test.go b/libgo/misc/cgo/testgodefs/testgodefs_test.go
index 438d23d..e4085f9 100644
--- a/libgo/misc/cgo/testgodefs/testgodefs_test.go
+++ b/libgo/misc/cgo/testgodefs/testgodefs_test.go
@@ -23,6 +23,8 @@ var filePrefixes = []string{
"fieldtypedef",
"issue37479",
"issue37621",
+ "issue38649",
+ "issue39534",
}
func TestGoDefs(t *testing.T) {
diff --git a/libgo/misc/cgo/testplugin/plugin_test.go b/libgo/misc/cgo/testplugin/plugin_test.go
index ab98f61..2875271 100644
--- a/libgo/misc/cgo/testplugin/plugin_test.go
+++ b/libgo/misc/cgo/testplugin/plugin_test.go
@@ -32,7 +32,7 @@ func TestMain(m *testing.M) {
}
func testMain(m *testing.M) int {
- // Copy testdata into GOPATH/src/testarchive, along with a go.mod file
+ // Copy testdata into GOPATH/src/testplugin, along with a go.mod file
// declaring the same path.
GOPATH, err := ioutil.TempDir("", "plugin_test")
diff --git a/libgo/misc/cgo/testshared/shared_test.go b/libgo/misc/cgo/testshared/shared_test.go
index b9ef6da..f8dabbe 100644
--- a/libgo/misc/cgo/testshared/shared_test.go
+++ b/libgo/misc/cgo/testshared/shared_test.go
@@ -38,7 +38,15 @@ var testWork = flag.Bool("testwork", false, "if true, log and do not delete the
// run runs a command and calls t.Errorf if it fails.
func run(t *testing.T, msg string, args ...string) {
+ runWithEnv(t, msg, nil, args...)
+}
+
+// runWithEnv runs a command under the given environment and calls t.Errorf if it fails.
+func runWithEnv(t *testing.T, msg string, env []string, args ...string) {
c := exec.Command(args[0], args[1:]...)
+ if len(env) != 0 {
+ c.Env = append(os.Environ(), env...)
+ }
if output, err := c.CombinedOutput(); err != nil {
t.Errorf("executing %s (%s) failed %s:\n%s", strings.Join(args, " "), msg, err, output)
}
@@ -105,6 +113,8 @@ func testMain(m *testing.M) (int, error) {
fmt.Printf("+ cd %s\n", modRoot)
}
os.Setenv("GOPATH", gopath)
+ // Explicitly override GOBIN as well, in case it was set through a GOENV file.
+ os.Setenv("GOBIN", filepath.Join(gopath, "bin"))
os.Chdir(modRoot)
os.Setenv("PWD", modRoot)
@@ -153,10 +163,6 @@ func TestMain(m *testing.M) {
log.SetFlags(log.Lshortfile)
flag.Parse()
- // Some of the tests install binaries into a custom GOPATH.
- // That won't work if GOBIN is set.
- os.Unsetenv("GOBIN")
-
exitCode, err := testMain(m)
if err != nil {
log.Fatal(err)
@@ -223,7 +229,7 @@ func cloneGOROOTDeps(goroot string) error {
for _, dir := range gorootDirs {
if testing.Verbose() {
- fmt.Fprintf(os.Stderr, "+ cp -r %s %s\n", filepath.Join(goroot, dir), filepath.Join(oldGOROOT, dir))
+ fmt.Fprintf(os.Stderr, "+ cp -r %s %s\n", filepath.Join(oldGOROOT, dir), filepath.Join(goroot, dir))
}
if err := overlayDir(filepath.Join(goroot, dir), filepath.Join(oldGOROOT, dir)); err != nil {
return err
@@ -1030,3 +1036,17 @@ func TestGeneratedHash(t *testing.T) {
goCmd(nil, "install", "-buildmode=shared", "-linkshared", "./issue30768/issue30768lib")
goCmd(nil, "test", "-linkshared", "./issue30768")
}
+
+// Test that packages can be added not in dependency order (here a depends on b, and a adds
+// before b). This could happen with e.g. go build -buildmode=shared std. See issue 39777.
+func TestPackageOrder(t *testing.T) {
+ goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue39777/a", "./issue39777/b")
+}
+
+// Test that GC data are generated correctly by the linker when it needs a type defined in
+// a shared library. See issue 39927.
+func TestGCData(t *testing.T) {
+ goCmd(t, "install", "-buildmode=shared", "-linkshared", "./gcdata/p")
+ goCmd(t, "build", "-linkshared", "./gcdata/main")
+ runWithEnv(t, "running gcdata/main", []string{"GODEBUG=clobberfree=1"}, "./main")
+}
diff --git a/libgo/misc/cgo/testshared/testdata/gcdata/main/main.go b/libgo/misc/cgo/testshared/testdata/gcdata/main/main.go
new file mode 100644
index 0000000..394862f
--- /dev/null
+++ b/libgo/misc/cgo/testshared/testdata/gcdata/main/main.go
@@ -0,0 +1,37 @@
+// 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.
+
+// Test that GC data is generated correctly for global
+// variables with types defined in a shared library.
+// See issue 39927.
+
+// This test run under GODEBUG=clobberfree=1. The check
+// *x[i] == 12345 depends on this debug mode to clobber
+// the value if the object is freed prematurely.
+
+package main
+
+import (
+ "fmt"
+ "runtime"
+ "testshared/gcdata/p"
+)
+
+var x p.T
+
+func main() {
+ for i := range x {
+ x[i] = new(int)
+ *x[i] = 12345
+ }
+ runtime.GC()
+ runtime.GC()
+ runtime.GC()
+ for i := range x {
+ if *x[i] != 12345 {
+ fmt.Printf("x[%d] == %d, want 12345\n", i, *x[i])
+ panic("FAIL")
+ }
+ }
+}
diff --git a/libgo/misc/cgo/testshared/testdata/gcdata/p/p.go b/libgo/misc/cgo/testshared/testdata/gcdata/p/p.go
new file mode 100644
index 0000000..1fee754
--- /dev/null
+++ b/libgo/misc/cgo/testshared/testdata/gcdata/p/p.go
@@ -0,0 +1,7 @@
+// 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.
+
+package p
+
+type T [10]*int
diff --git a/libgo/misc/cgo/testshared/testdata/issue39777/a/a.go b/libgo/misc/cgo/testshared/testdata/issue39777/a/a.go
new file mode 100644
index 0000000..c7bf835
--- /dev/null
+++ b/libgo/misc/cgo/testshared/testdata/issue39777/a/a.go
@@ -0,0 +1,9 @@
+// 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.
+
+package a
+
+import "testshared/issue39777/b"
+
+func F() { b.F() }
diff --git a/libgo/misc/cgo/testshared/testdata/issue39777/b/b.go b/libgo/misc/cgo/testshared/testdata/issue39777/b/b.go
new file mode 100644
index 0000000..4e68196
--- /dev/null
+++ b/libgo/misc/cgo/testshared/testdata/issue39777/b/b.go
@@ -0,0 +1,7 @@
+// 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.
+
+package b
+
+func F() {}
diff --git a/libgo/misc/cgo/testso/so_test.go b/libgo/misc/cgo/testso/so_test.go
index 9c7f272..bdd6bd8 100644
--- a/libgo/misc/cgo/testso/so_test.go
+++ b/libgo/misc/cgo/testso/so_test.go
@@ -20,16 +20,14 @@ import (
func requireTestSOSupported(t *testing.T) {
t.Helper()
switch runtime.GOARCH {
- case "arm", "arm64":
+ case "arm64":
if runtime.GOOS == "darwin" {
t.Skip("No exec facility on iOS.")
}
case "ppc64":
if runtime.GOOS == "linux" {
- t.Skip("External linking not implemented on aix/ppc64 (issue #8912).")
+ t.Skip("External linking not implemented on linux/ppc64 (issue #8912).")
}
- case "mips64le", "mips64":
- t.Skip("External linking not implemented on mips64.")
}
if runtime.GOOS == "android" {
t.Skip("No exec facility on Android.")
diff --git a/libgo/misc/cgo/testsovar/so_test.go b/libgo/misc/cgo/testsovar/so_test.go
index 9c7f272..bdd6bd8 100644
--- a/libgo/misc/cgo/testsovar/so_test.go
+++ b/libgo/misc/cgo/testsovar/so_test.go
@@ -20,16 +20,14 @@ import (
func requireTestSOSupported(t *testing.T) {
t.Helper()
switch runtime.GOARCH {
- case "arm", "arm64":
+ case "arm64":
if runtime.GOOS == "darwin" {
t.Skip("No exec facility on iOS.")
}
case "ppc64":
if runtime.GOOS == "linux" {
- t.Skip("External linking not implemented on aix/ppc64 (issue #8912).")
+ t.Skip("External linking not implemented on linux/ppc64 (issue #8912).")
}
- case "mips64le", "mips64":
- t.Skip("External linking not implemented on mips64.")
}
if runtime.GOOS == "android" {
t.Skip("No exec facility on Android.")