From: Johan Brandhorst-Satzkorn Date: Sat, 25 Mar 2023 05:25:18 +0000 (-0700) Subject: cmd/compile: allow go:wasmimport in syscall X-Git-Tag: go1.21rc1~1093 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ed9744dff5341ab692154eab1e6e0f1a3c138733;p=gostls13.git cmd/compile: allow go:wasmimport in syscall The go:wasmimport compiler directive is used by the wasi port to access host APIs, some of need to implemented in the syscall package. Co-authored-by: Richard Musiol Co-authored-by: Achille Roussel Co-authored-by: Julien Fabre Co-authored-by: Evan Phoenix Change-Id: I3851e154c6989094effcd25bba5864faa133564e Reviewed-on: https://go-review.googlesource.com/c/go/+/479615 Reviewed-by: Cherry Mui Auto-Submit: Johan Brandhorst-Satzkorn Reviewed-by: Matthew Dempsky TryBot-Result: Gopher Robot Run-TryBot: Johan Brandhorst-Satzkorn --- diff --git a/src/cmd/compile/internal/noder/noder.go b/src/cmd/compile/internal/noder/noder.go index c846130976..483ff64686 100644 --- a/src/cmd/compile/internal/noder/noder.go +++ b/src/cmd/compile/internal/noder/noder.go @@ -237,7 +237,7 @@ func (p *noder) pragma(pos syntax.Pos, blankLine bool, text string, old syntax.P p.error(syntax.Error{Pos: pos, Msg: "usage: //go:wasmimport importmodule importname"}) break } - if !base.Flag.CompilingRuntime && base.Ctxt.Pkgpath != "syscall/js" && base.Ctxt.Pkgpath != "syscall/js_test" { + if !base.Flag.CompilingRuntime && base.Ctxt.Pkgpath != "syscall/js" && base.Ctxt.Pkgpath != "syscall/js_test" && base.Ctxt.Pkgpath != "syscall" { p.error(syntax.Error{Pos: pos, Msg: "//go:wasmimport directive cannot be used outside of runtime or syscall/js"}) break }