Skip to content

Commit 219e3c5

Browse files
committed
compiler: ignore go:wasmexport directives on non-wasm architectures
1 parent abaadef commit 219e3c5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

compiler/symbol.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,10 @@ func (c *compilerContext) parsePragmas(info *functionInfo, f *ssa.Function) {
340340
info.wasmModule = parts[1]
341341
info.wasmName = parts[2]
342342
case "//go:wasmexport":
343+
if c.archFamily() != "wasm32" {
344+
// go:wasmimport is ignored on non-wasm architectures
345+
continue
346+
}
343347
if f.Blocks == nil {
344348
c.addError(f.Pos(), "can only use //go:wasmexport on definitions")
345349
continue
@@ -357,9 +361,6 @@ func (c *compilerContext) parsePragmas(info *functionInfo, f *ssa.Function) {
357361
c.addError(f.Pos(), fmt.Sprintf("//go:wasmexport does not allow main.main to be exported with -buildmode=%s", c.BuildMode))
358362
continue
359363
}
360-
if c.archFamily() != "wasm32" {
361-
c.addError(f.Pos(), "//go:wasmexport is only supported on wasm")
362-
}
363364
c.checkWasmImportExport(f, comment.Text)
364365
info.wasmExport = name
365366
info.wasmExportPos = comment.Slash

0 commit comments

Comments
 (0)