From 457a76b49a65b6416ce14670f7de04814c6cb3c5 Mon Sep 17 00:00:00 2001 From: Matt Clarkson Date: Thu, 28 Mar 2024 15:59:21 +0000 Subject: [PATCH] Ignore `purego` build constraint (#1767) `purego` is a proposed[1] de-facto build constraint to denote building _only_ Go code. We must ignore this constraint to make sure that files that toggle on `purego` are added to the Bazel target `srcs` and let the compiler decide if they should be compiled or not. [1]: https://github.com/golang/go/issues/23172 --- language/go/build_constraints.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/language/go/build_constraints.go b/language/go/build_constraints.go index 1ce071a95..8bae3ce30 100644 --- a/language/go/build_constraints.go +++ b/language/go/build_constraints.go @@ -307,13 +307,13 @@ func matchAuto(tokens []string) (*buildTags, error) { return newBuildTags(x) } -// isIgnoredTag returns whether the tag is "cgo" or is a release tag. +// isIgnoredTag returns whether the tag is "cgo", "purego", "race", "msan" or is a release tag. // Release tags match the pattern "go[0-9]\.[0-9]+". // Gazelle won't consider whether an ignored tag is satisfied when evaluating // build constraints for a file and will instead defer to the compiler at compile // time. func isIgnoredTag(tag string) bool { - if tag == "cgo" || tag == "race" || tag == "msan" { + if tag == "cgo" || tag == "purego" || tag == "race" || tag == "msan" { return true } if len(tag) < 5 || !strings.HasPrefix(tag, "go") {