mirror of
https://github.com/golang/go.git
synced 2025-05-06 08:03:03 +00:00
cmd/api: explicit tagKey with GOOS and GOARCH
The origin tagKey is just dirname if no tags input which will cause pkgCache missmatch if other imported pkg explicit on GOARCH or GOOS This CL will add GOOS and GOARCH to tagKey Fixes #8425 Fixes #21181 Change-Id: Ifc189cf6746d753ad7c7e5bb60621297fc0a4e35 Reviewed-on: https://go-review.googlesource.com/c/138315 Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
415e948eae
commit
28fa1da9db
@ -6,6 +6,8 @@ pkg os, const ModeType = 2399141888
|
|||||||
pkg os, const ModeType = 2399666176
|
pkg os, const ModeType = 2399666176
|
||||||
pkg os (linux-arm), const O_SYNC = 4096
|
pkg os (linux-arm), const O_SYNC = 4096
|
||||||
pkg os (linux-arm-cgo), 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), const ImplementsGetwd = false
|
||||||
pkg syscall (darwin-386), func Fchflags(string, int) error
|
pkg syscall (darwin-386), func Fchflags(string, int) error
|
||||||
pkg syscall (darwin-386-cgo), const ImplementsGetwd = false
|
pkg syscall (darwin-386-cgo), const ImplementsGetwd = false
|
||||||
|
@ -385,9 +385,7 @@ func (w *Walker) parseFile(dir, file string) (*ast.File, error) {
|
|||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// The package cache doesn't operate correctly in rare (so far artificial)
|
// Disable before debugging non-obvious errors from the type-checker.
|
||||||
// circumstances (issue 8425). Disable before debugging non-obvious errors
|
|
||||||
// from the type-checker.
|
|
||||||
const usePkgCache = true
|
const usePkgCache = true
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -398,7 +396,7 @@ var (
|
|||||||
// tagKey returns the tag-based key to use in the pkgCache.
|
// 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.
|
// 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
|
// 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,
|
// The tags list, which came from go/build's Package.AllTags,
|
||||||
// is known to be sorted.
|
// is known to be sorted.
|
||||||
func tagKey(dir string, context *build.Context, tags []string) string {
|
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)
|
// TODO: ReleaseTags (need to load default)
|
||||||
key := dir
|
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 {
|
for _, tag := range tags {
|
||||||
if ctags[tag] {
|
if ctags[tag] {
|
||||||
key += "," + tag
|
key += "," + tag
|
||||||
|
ctags[tag] = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return key
|
return key
|
||||||
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
5
src/cmd/api/testdata/src/issue21181/dep/p.go
vendored
Normal file
5
src/cmd/api/testdata/src/issue21181/dep/p.go
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package dep
|
||||||
|
|
||||||
|
type Interface interface {
|
||||||
|
N([]byte)
|
||||||
|
}
|
1
src/cmd/api/testdata/src/issue21181/dep/p_amd64.go
vendored
Normal file
1
src/cmd/api/testdata/src/issue21181/dep/p_amd64.go
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
package dep
|
5
src/cmd/api/testdata/src/issue21181/indirect/p.go
vendored
Normal file
5
src/cmd/api/testdata/src/issue21181/indirect/p.go
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package indirect
|
||||||
|
|
||||||
|
import "dep"
|
||||||
|
|
||||||
|
func F(dep.Interface) {}
|
9
src/cmd/api/testdata/src/issue21181/p/p.go
vendored
Normal file
9
src/cmd/api/testdata/src/issue21181/p/p.go
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package p
|
||||||
|
|
||||||
|
import (
|
||||||
|
"dep"
|
||||||
|
)
|
||||||
|
|
||||||
|
type algo struct {
|
||||||
|
indrt func(dep.Interface)
|
||||||
|
}
|
7
src/cmd/api/testdata/src/issue21181/p/p_amd64.go
vendored
Normal file
7
src/cmd/api/testdata/src/issue21181/p/p_amd64.go
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package p
|
||||||
|
|
||||||
|
import "indirect"
|
||||||
|
|
||||||
|
var in = []algo{
|
||||||
|
{indirect.F},
|
||||||
|
}
|
11
src/cmd/api/testdata/src/issue21181/p/p_generic.go
vendored
Normal file
11
src/cmd/api/testdata/src/issue21181/p/p_generic.go
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// +build !amd64
|
||||||
|
|
||||||
|
package p
|
||||||
|
|
||||||
|
import (
|
||||||
|
"indirect"
|
||||||
|
)
|
||||||
|
|
||||||
|
var in = []algo{
|
||||||
|
{indirect.F},
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user