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
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 (
// 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 {
}
// 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
}
}
}
+
+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)
+ }
+}