aboutsummaryrefslogtreecommitdiff
path: root/libgo/misc/cgo/testshared
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-02-11 14:53:56 -0800
committerIan Lance Taylor <iant@golang.org>2022-02-11 15:01:19 -0800
commit8dc2499aa62f768c6395c9754b8cabc1ce25c494 (patch)
tree43d7fd2bbfd7ad8c9625a718a5e8718889351994 /libgo/misc/cgo/testshared
parent9a56779dbc4e2d9c15be8d31e36f2f59be7331a8 (diff)
downloadgcc-8dc2499aa62f768c6395c9754b8cabc1ce25c494.zip
gcc-8dc2499aa62f768c6395c9754b8cabc1ce25c494.tar.gz
gcc-8dc2499aa62f768c6395c9754b8cabc1ce25c494.tar.bz2
libgo: update to Go1.18beta2
gotools/ * Makefile.am (go_cmd_cgo_files): Add ast_go118.go (check-go-tool): Copy golang.org/x/tools directories. * Makefile.in: Regenerate. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/384695
Diffstat (limited to 'libgo/misc/cgo/testshared')
-rw-r--r--libgo/misc/cgo/testshared/shared_test.go35
-rw-r--r--libgo/misc/cgo/testshared/testdata/issue47837/a/a.go19
-rw-r--r--libgo/misc/cgo/testshared/testdata/issue47837/main/main.go14
3 files changed, 61 insertions, 7 deletions
diff --git a/libgo/misc/cgo/testshared/shared_test.go b/libgo/misc/cgo/testshared/shared_test.go
index e77f848..b78083b 100644
--- a/libgo/misc/cgo/testshared/shared_test.go
+++ b/libgo/misc/cgo/testshared/shared_test.go
@@ -20,6 +20,7 @@ import (
"regexp"
"runtime"
"sort"
+ "strconv"
"strings"
"testing"
"time"
@@ -55,7 +56,7 @@ func runWithEnv(t *testing.T, msg string, env []string, args ...string) {
// t.Fatalf if the command fails.
func goCmd(t *testing.T, args ...string) string {
newargs := []string{args[0]}
- if *testX {
+ if *testX && args[0] != "env" {
newargs = append(newargs, "-x")
}
newargs = append(newargs, args[1:]...)
@@ -461,7 +462,9 @@ func TestTrivialExecutable(t *testing.T) {
run(t, "trivial executable", "../../bin/trivial")
AssertIsLinkedTo(t, "../../bin/trivial", soname)
AssertHasRPath(t, "../../bin/trivial", gorootInstallDir)
- checkSize(t, "../../bin/trivial", 100000) // it is 19K on linux/amd64, 100K should be enough
+ // It is 19K on linux/amd64, with separate-code in binutils ld and 64k being most common alignment
+ // 4*64k should be enough, but this might need revision eventually.
+ checkSize(t, "../../bin/trivial", 256000)
}
// Build a trivial program in PIE mode that links against the shared runtime and check it runs.
@@ -470,7 +473,9 @@ func TestTrivialExecutablePIE(t *testing.T) {
run(t, "trivial executable", "./trivial.pie")
AssertIsLinkedTo(t, "./trivial.pie", soname)
AssertHasRPath(t, "./trivial.pie", gorootInstallDir)
- checkSize(t, "./trivial.pie", 100000) // it is 19K on linux/amd64, 100K should be enough
+ // It is 19K on linux/amd64, with separate-code in binutils ld and 64k being most common alignment
+ // 4*64k should be enough, but this might need revision eventually.
+ checkSize(t, "./trivial.pie", 256000)
}
// Check that the file size does not exceed a limit.
@@ -694,7 +699,15 @@ func requireGccgo(t *testing.T) {
if err != nil {
t.Fatalf("%s -dumpversion failed: %v\n%s", gccgoPath, err, output)
}
- if string(output) < "5" {
+ dot := bytes.Index(output, []byte{'.'})
+ if dot > 0 {
+ output = output[:dot]
+ }
+ major, err := strconv.Atoi(string(output))
+ if err != nil {
+ t.Skipf("can't parse gccgo version number %s", output)
+ }
+ if major < 5 {
t.Skipf("gccgo too old (%s)", strings.TrimSpace(string(output)))
}
@@ -1033,7 +1046,7 @@ func TestGlobal(t *testing.T) {
// Run a test using -linkshared of an installed shared package.
// Issue 26400.
func TestTestInstalledShared(t *testing.T) {
- goCmd(nil, "test", "-linkshared", "-test.short", "sync/atomic")
+ goCmd(t, "test", "-linkshared", "-test.short", "sync/atomic")
}
// Test generated pointer method with -linkshared.
@@ -1045,8 +1058,8 @@ func TestGeneratedMethod(t *testing.T) {
// Test use of shared library struct with generated hash function.
// Issue 30768.
func TestGeneratedHash(t *testing.T) {
- goCmd(nil, "install", "-buildmode=shared", "-linkshared", "./issue30768/issue30768lib")
- goCmd(nil, "test", "-linkshared", "./issue30768")
+ goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue30768/issue30768lib")
+ goCmd(t, "test", "-linkshared", "./issue30768")
}
// Test that packages can be added not in dependency order (here a depends on b, and a adds
@@ -1070,3 +1083,11 @@ func TestIssue44031(t *testing.T) {
goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue44031/b")
goCmd(t, "run", "-linkshared", "./issue44031/main")
}
+
+// Test that we use a variable from shared libraries (which implement an
+// interface in shared libraries.). A weak reference is used in the itab
+// in main process. It can cause unreacheble panic. See issue 47873.
+func TestIssue47873(t *testing.T) {
+ goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue47837/a")
+ goCmd(t, "run", "-linkshared", "./issue47837/main")
+}
diff --git a/libgo/misc/cgo/testshared/testdata/issue47837/a/a.go b/libgo/misc/cgo/testshared/testdata/issue47837/a/a.go
new file mode 100644
index 0000000..68588ed
--- /dev/null
+++ b/libgo/misc/cgo/testshared/testdata/issue47837/a/a.go
@@ -0,0 +1,19 @@
+// Copyright 2021 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
+
+type A interface {
+ M()
+}
+
+//go:noinline
+func TheFuncWithArgA(a A) {
+ a.M()
+}
+
+type ImplA struct{}
+
+//go:noinline
+func (A *ImplA) M() {}
diff --git a/libgo/misc/cgo/testshared/testdata/issue47837/main/main.go b/libgo/misc/cgo/testshared/testdata/issue47837/main/main.go
new file mode 100644
index 0000000..77c6f34
--- /dev/null
+++ b/libgo/misc/cgo/testshared/testdata/issue47837/main/main.go
@@ -0,0 +1,14 @@
+// Copyright 2021 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 main
+
+import (
+ "testshared/issue47837/a"
+)
+
+func main() {
+ var vara a.ImplA
+ a.TheFuncWithArgA(&vara)
+}