summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/except.txt2
-rw-r--r--src/cmd/api/goapi.go14
-rw-r--r--src/cmd/api/goapi_test.go15
-rw-r--r--src/cmd/api/testdata/src/issue21181/dep/p.go5
-rw-r--r--src/cmd/api/testdata/src/issue21181/dep/p_amd64.go1
-rw-r--r--src/cmd/api/testdata/src/issue21181/indirect/p.go5
-rw-r--r--src/cmd/api/testdata/src/issue21181/p/p.go9
-rw-r--r--src/cmd/api/testdata/src/issue21181/p/p_amd64.go7
-rw-r--r--src/cmd/api/testdata/src/issue21181/p/p_generic.go11
9 files changed, 65 insertions, 4 deletions
diff --git a/api/except.txt b/api/except.txt
index 9f7f3fe934..90b79f1592 100644
--- a/api/except.txt
+++ b/api/except.txt
@@ -6,6 +6,8 @@ pkg os, const ModeType = 2399141888
pkg os, const ModeType = 2399666176
pkg os (linux-arm), const O_SYNC = 4096
pkg os (linux-arm-cgo), const O_SYNC = 4096
+pkg os (linux-arm), const O_SYNC = 1052672
+pkg os (linux-arm-cgo), const O_SYNC = 1052672
pkg syscall (darwin-386), const ImplementsGetwd = false
pkg syscall (darwin-386), func Fchflags(string, int) error
pkg syscall (darwin-386-cgo), const ImplementsGetwd = false
diff --git a/src/cmd/api/goapi.go b/src/cmd/api/goapi.go
index 8cc78c01ed..9698f25b51 100644
--- a/src/cmd/api/goapi.go
+++ b/src/cmd/api/goapi.go
@@ -385,9 +385,7 @@ func (w *Walker) parseFile(dir, file string) (*ast.File, error) {
return f, nil
}
-// The package cache doesn't operate correctly in rare (so far artificial)
-// circumstances (issue 8425). Disable before debugging non-obvious errors
-// from the type-checker.
+// Disable before debugging non-obvious errors from the type-checker.
const usePkgCache = true
var (
@@ -398,7 +396,7 @@ var (
// tagKey returns the tag-based key to use in the pkgCache.
// It is a comma-separated string; the first part is dir, the rest tags.
// The satisfied tags are derived from context but only those that
-// matter (the ones listed in the tags argument) are used.
+// matter (the ones listed in the tags argument plus GOOS and GOARCH) are used.
// The tags list, which came from go/build's Package.AllTags,
// is known to be sorted.
func tagKey(dir string, context *build.Context, tags []string) string {
@@ -414,9 +412,17 @@ func tagKey(dir string, context *build.Context, tags []string) string {
}
// TODO: ReleaseTags (need to load default)
key := dir
+
+ // explicit on GOOS and GOARCH as global cache will use "all" cached packages for
+ // an indirect imported package. See https://github.com/golang/go/issues/21181
+ // for more detail.
+ tags = append(tags, context.GOOS, context.GOARCH)
+ sort.Strings(tags)
+
for _, tag := range tags {
if ctags[tag] {
key += "," + tag
+ ctags[tag] = false
}
}
return key
diff --git a/src/cmd/api/goapi_test.go b/src/cmd/api/goapi_test.go
index 3c4e50a21a..1c8e2a345b 100644
--- a/src/cmd/api/goapi_test.go
+++ b/src/cmd/api/goapi_test.go
@@ -188,3 +188,18 @@ func BenchmarkAll(b *testing.B) {
}
}
}
+
+func TestIssue21181(t *testing.T) {
+ for _, c := range contexts {
+ c.Compiler = build.Default.Compiler
+ }
+ for _, context := range contexts {
+ w := NewWalker(context, "testdata/src/issue21181")
+ pkg, err := w.Import("p")
+ if err != nil {
+ t.Fatalf("%s: (%s-%s) %s %v", err, context.GOOS, context.GOARCH,
+ pkg.Name(), w.imported)
+ }
+ w.export(pkg)
+ }
+}
diff --git a/src/cmd/api/testdata/src/issue21181/dep/p.go b/src/cmd/api/testdata/src/issue21181/dep/p.go
new file mode 100644
index 0000000000..2d8e0c4cce
--- /dev/null
+++ b/src/cmd/api/testdata/src/issue21181/dep/p.go
@@ -0,0 +1,5 @@
+package dep
+
+type Interface interface {
+ N([]byte)
+}
diff --git a/src/cmd/api/testdata/src/issue21181/dep/p_amd64.go b/src/cmd/api/testdata/src/issue21181/dep/p_amd64.go
new file mode 100644
index 0000000000..8a2343a0e2
--- /dev/null
+++ b/src/cmd/api/testdata/src/issue21181/dep/p_amd64.go
@@ -0,0 +1 @@
+package dep
diff --git a/src/cmd/api/testdata/src/issue21181/indirect/p.go b/src/cmd/api/testdata/src/issue21181/indirect/p.go
new file mode 100644
index 0000000000..e37cf3fc44
--- /dev/null
+++ b/src/cmd/api/testdata/src/issue21181/indirect/p.go
@@ -0,0 +1,5 @@
+package indirect
+
+import "dep"
+
+func F(dep.Interface) {}
diff --git a/src/cmd/api/testdata/src/issue21181/p/p.go b/src/cmd/api/testdata/src/issue21181/p/p.go
new file mode 100644
index 0000000000..a704160edc
--- /dev/null
+++ b/src/cmd/api/testdata/src/issue21181/p/p.go
@@ -0,0 +1,9 @@
+package p
+
+import (
+ "dep"
+)
+
+type algo struct {
+ indrt func(dep.Interface)
+}
diff --git a/src/cmd/api/testdata/src/issue21181/p/p_amd64.go b/src/cmd/api/testdata/src/issue21181/p/p_amd64.go
new file mode 100644
index 0000000000..02b4cbf036
--- /dev/null
+++ b/src/cmd/api/testdata/src/issue21181/p/p_amd64.go
@@ -0,0 +1,7 @@
+package p
+
+import "indirect"
+
+var in = []algo{
+ {indirect.F},
+}
diff --git a/src/cmd/api/testdata/src/issue21181/p/p_generic.go b/src/cmd/api/testdata/src/issue21181/p/p_generic.go
new file mode 100644
index 0000000000..4d75809676
--- /dev/null
+++ b/src/cmd/api/testdata/src/issue21181/p/p_generic.go
@@ -0,0 +1,11 @@
+// +build !amd64
+
+package p
+
+import (
+ "indirect"
+)
+
+var in = []algo{
+ {indirect.F},
+}