]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: only use check cache action's dependencies to build vet config
authorMichael Matloob <matloob@golang.org>
Thu, 8 Jan 2026 17:45:34 +0000 (12:45 -0500)
committerMichael Matloob <matloob@google.com>
Fri, 9 Jan 2026 15:54:33 +0000 (07:54 -0800)
We manipulate the dependencies of the build action when adding the
non-test variant of the package being tested as a dependency for the
test, so the set of deps of the build package doesn't correctly
represent the dependencies of the package that have been built. Restrict
the set of dependencies we use to populate the vet data to the actual
build dependencies depended on by the check cache action so we don't
check an action that we don't actually depend on (and which may not have
completed yet!)

Fixes #75380

Change-Id: I029080d00b3b10a837abcfb7039e00206a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/734961
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/go/internal/work/exec.go

index f2d1b1040b223b1f2a50435277032b1b797c44f3..0afdce235688088bab6051584c7af6c6b1c134df 100644 (file)
@@ -627,7 +627,7 @@ func (b *Builder) checkCacheForBuild(a, buildAction *Action, covMetaFileName str
        // If we are going to do a full build anyway,
        // we're going to regenerate the files in the build action anyway.
        if need == needVet {
-               if err := b.loadCachedVet(buildAction); err == nil {
+               if err := b.loadCachedVet(buildAction, a.Deps); err == nil {
                        need &^= needVet
                }
        }
@@ -841,7 +841,7 @@ func (b *Builder) build(ctx context.Context, a *Action) (err error) {
 
        // Prepare Go vet config if needed.
        if need&needVet != 0 {
-               buildVetConfig(a, srcfiles)
+               buildVetConfig(a, srcfiles, a.Deps)
                need &^= needVet
        }
        if need&needCompiledGoFiles != 0 {
@@ -1121,7 +1121,7 @@ func (b *Builder) cacheSrcFiles(a *Action, srcfiles []string) {
        cache.PutBytes(c, cache.Subkey(a.actionID, "srcfiles"), buf.Bytes())
 }
 
-func (b *Builder) loadCachedVet(a *Action) error {
+func (b *Builder) loadCachedVet(a *Action, vetDeps []*Action) error {
        c := cache.Default()
        list, _, err := cache.GetBytes(c, cache.Subkey(a.actionID, "srcfiles"))
        if err != nil {
@@ -1141,7 +1141,7 @@ func (b *Builder) loadCachedVet(a *Action) error {
                }
                srcfiles = append(srcfiles, a.Objdir+name)
        }
-       buildVetConfig(a, srcfiles)
+       buildVetConfig(a, srcfiles, vetDeps)
        return nil
 }
 
@@ -1197,7 +1197,7 @@ type vetConfig struct {
        SucceedOnTypecheckFailure bool // awful hack; see #18395 and below
 }
 
-func buildVetConfig(a *Action, srcfiles []string) {
+func buildVetConfig(a *Action, srcfiles []string, vetDeps []*Action) {
        // Classify files based on .go extension.
        // srcfiles does not include raw cgo files.
        var gofiles, nongofiles []string
@@ -1253,7 +1253,7 @@ func buildVetConfig(a *Action, srcfiles []string) {
                vcfgMapped[p] = true
        }
 
-       for _, a1 := range a.Deps {
+       for _, a1 := range vetDeps {
                p1 := a1.Package
                if p1 == nil || p1.ImportPath == "" || p1 == a.Package {
                        continue