From 1f3fd8f91df09df03dc47ebf10dd05f47b009033 Mon Sep 17 00:00:00 2001 From: Randy Reddig Date: Mon, 11 Nov 2024 12:48:10 -0700 Subject: [PATCH] compiler: ignore go:wasmexport directives on non-wasm architectures --- compiler/symbol.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/symbol.go b/compiler/symbol.go index 93c27803e2..cf806be317 100644 --- a/compiler/symbol.go +++ b/compiler/symbol.go @@ -350,6 +350,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 @@ -367,9 +371,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