Skip to content

Commit

Permalink
compiler: ignore go:wasmexport directives on non-wasm architectures
Browse files Browse the repository at this point in the history
  • Loading branch information
ydnar committed Nov 11, 2024
1 parent abaadef commit 219e3c5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions compiler/symbol.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 219e3c5

Please sign in to comment.