Skip to content

Commit 2b8e143

Browse files
committed
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 golang#11041 Change-Id: I0ae807dbbd5fb67ca21d0157fe180237a074113a Reviewed-on: https://go-review.googlesource.com/27151 Run-TryBot: Josh Bleecher Snyder <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Rob Pike <[email protected]>
1 parent 752e161 commit 2b8e143

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/cmd/vet/asmdecl.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"bytes"
1111
"fmt"
1212
"go/ast"
13+
"go/build"
1314
"go/token"
1415
"regexp"
1516
"strconv"
@@ -179,8 +180,17 @@ Files:
179180
if m := asmTEXT.FindStringSubmatch(line); m != nil {
180181
flushRet()
181182
if arch == "" {
182-
f.Warnf(token.NoPos, "%s: cannot determine architecture for assembly file", f.name)
183-
continue Files
183+
for _, a := range arches {
184+
if a.name == build.Default.GOARCH {
185+
arch = a.name
186+
archDef = a
187+
break
188+
}
189+
}
190+
if arch == "" {
191+
f.Warnf(token.NoPos, "%s: cannot determine architecture for assembly file", f.name)
192+
continue Files
193+
}
184194
}
185195
fnName = m[1]
186196
fn = knownFunc[m[1]][arch]

0 commit comments

Comments
 (0)