diff --git a/compiler/symbol.go b/compiler/symbol.go index 9b9b1d10e8..f8b17a67d5 100644 --- a/compiler/symbol.go +++ b/compiler/symbol.go @@ -340,6 +340,10 @@ func (c *compilerContext) parsePragmas(info *functionInfo, f *ssa.Function) { info.wasmModule = parts[1] info.wasmName = parts[2] case "//go:wasmexport": + if c.archFamily() != "wasm32" { + // go:wasmimport is ignored on non-wasm architectures + continue + } if f.Blocks == nil { c.addError(f.Pos(), "can only use //go:wasmexport on definitions") continue @@ -357,9 +361,6 @@ func (c *compilerContext) parsePragmas(info *functionInfo, f *ssa.Function) { c.addError(f.Pos(), fmt.Sprintf("//go:wasmexport does not allow main.main to be exported with -buildmode=%s", c.BuildMode)) continue } - if c.archFamily() != "wasm32" { - c.addError(f.Pos(), "//go:wasmexport is only supported on wasm") - } c.checkWasmImportExport(f, comment.Text) info.wasmExport = name info.wasmExportPos = comment.Slash