From: Josh Bleecher Snyder Date: Mon, 11 Jul 2016 19:19:51 +0000 (-0700) Subject: cmd/vet: infer asm arch from build context X-Git-Tag: go1.8beta1~1810 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2b8e143dc302d2f3817cb3df1c1cc0b2cde3bbc1;p=gostls13.git cmd/vet: infer asm arch from build context If we cannot infer the asm arch from the filename or the build tags, assume that it is the current build arch. Assembly files with no restrictions ought to be usable on all arches. Updates #11041 Change-Id: I0ae807dbbd5fb67ca21d0157fe180237a074113a Reviewed-on: https://go-review.googlesource.com/27151 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Rob Pike --- diff --git a/src/cmd/vet/asmdecl.go b/src/cmd/vet/asmdecl.go index d543b2ee5c..bd336cb662 100644 --- a/src/cmd/vet/asmdecl.go +++ b/src/cmd/vet/asmdecl.go @@ -10,6 +10,7 @@ import ( "bytes" "fmt" "go/ast" + "go/build" "go/token" "regexp" "strconv" @@ -179,8 +180,17 @@ Files: if m := asmTEXT.FindStringSubmatch(line); m != nil { flushRet() if arch == "" { - f.Warnf(token.NoPos, "%s: cannot determine architecture for assembly file", f.name) - continue Files + for _, a := range arches { + if a.name == build.Default.GOARCH { + arch = a.name + archDef = a + break + } + } + if arch == "" { + f.Warnf(token.NoPos, "%s: cannot determine architecture for assembly file", f.name) + continue Files + } } fnName = m[1] fn = knownFunc[m[1]][arch]