From 9ae1c966bd53b88d6fd76b396a120568f2d35a8b Mon Sep 17 00:00:00 2001 From: Samuel Littley Date: Fri, 13 Dec 2024 18:03:49 +0000 Subject: [PATCH] Fix BuildTarget.ProvideFor not checking named data when deciding whether to skip resolution. (#3316) --- ChangeLog | 7 ++++++- VERSION | 2 +- src/core/build_target.go | 15 +++++++++++---- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5783e6f4c..c71ab12ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ +Version 17.12.7 +--------------- + * Fix BuildTarget.ProvideFor not checking named data when deciding whether + to skip resolution. (#3316) + Version 17.12.6 --------------- +--------------- * Add goroutine labels to track what they are getting up to if we suspect a hang (#3292) * Fix deadlock with queuing data for tests (#3306) * Fix potential subinclude lockup (#3305) diff --git a/VERSION b/VERSION index 3c92e1f33..8c2aa857b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -17.12.6 +17.12.7 diff --git a/src/core/build_target.go b/src/core/build_target.go index 9978e2f85..5e523be46 100644 --- a/src/core/build_target.go +++ b/src/core/build_target.go @@ -1205,6 +1205,15 @@ func (target *BuildTarget) ProvideFor(other *BuildTarget) []BuildLabel { return []BuildLabel{target.Label} } +func (target *BuildTarget) isDataFor(other *BuildTarget) bool { + for _, data := range other.AllData() { + if label, ok := data.Label(); ok && label == target.Label { + return true + } + } + return false +} + // provideFor is like ProvideFor but returns an empty slice if there is a direct dependency. // It's a small optimisation to save allocating extra slices. func (target *BuildTarget) provideFor(other *BuildTarget) ([]BuildLabel, bool) { @@ -1214,10 +1223,8 @@ func (target *BuildTarget) provideFor(other *BuildTarget) ([]BuildLabel, bool) { return nil, false } // Never do this if the other target has a data or tool dependency on us. - for _, data := range other.Data { - if label, ok := data.Label(); ok && label == target.Label { - return nil, false - } + if target.isDataFor(other) { + return nil, false } if other.IsTool(target.Label) { return nil, false