]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: allow go:wasmimport in syscall
authorJohan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Sat, 25 Mar 2023 05:25:18 +0000 (22:25 -0700)
committerGopher Robot <gobot@golang.org>
Thu, 30 Mar 2023 18:50:54 +0000 (18:50 +0000)
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 <neelance@gmail.com>
Co-authored-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Julien Fabre <ju.pryz@gmail.com>
Co-authored-by: Evan Phoenix <evan@phx.io>
Change-Id: I3851e154c6989094effcd25bba5864faa133564e
Reviewed-on: https://go-review.googlesource.com/c/go/+/479615
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>

src/cmd/compile/internal/noder/noder.go

index c8461309763e04c7a7c8de352d36cd5639737801..483ff646860ce939cb0dcc4b7976a0e99f6e7f0d 100644 (file)
@@ -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
                }