go --> wasm: syscall.Mmap

122 views
Skip to first unread message

Stan Srednyak

unread,
Feb 17, 2023, 9:47:10 AM2/17/23
to golang-nuts
I have a Go code that I am trying to compile to .wasm. The code uses syscall.Mmap.

I am getting  undefined: syscall.Mmap


What is this error and what do I do with it?


Stan Srednyak

Ian Lance Taylor

unread,
Feb 17, 2023, 11:14:43 AM2/17/23
to Stan Srednyak, golang-nuts
The syscall package provides system dependent functionality.  Wasm does not support memory mapping, so syscall.Mmap does not exist on Wasm.

In order to make any useful suggestions we would have to know why your Go code is calling Mmap.

Ian

Stan Srednyak

unread,
Feb 17, 2023, 12:12:05 PM2/17/23
to Ian Lance Taylor, golang-nuts
hi Ian,

thanks for your reply.
The Mmap functionality is crucial for my app. I am dealing with large binary trees that do not fit RAM. I implemented them on disk, and for this, Mmap is crucial.

Now I have a client that wants to run the app from inside a virtual box, and for security reason, they want .wasm code.

Stan Srednyak

Ian Lance Taylor

unread,
Feb 17, 2023, 3:37:19 PM2/17/23
to Stan Srednyak, golang-nuts
On Fri, Feb 17, 2023 at 9:11 AM Stan Srednyak <stan....@gmail.com> wrote:
>
> thanks for your reply.
> The Mmap functionality is crucial for my app. I am dealing with large binary trees that do not fit RAM. I implemented them on disk, and for this, Mmap is crucial.
>
> Now I have a client that wants to run the app from inside a virtual box, and for security reason, they want .wasm code.

Sorry, I have no idea whether this is possible using wasm. I suspect
that it is not but I am not an expert.

Ian

Robert Engels

unread,
Feb 17, 2023, 3:45:15 PM2/17/23
to Ian Lance Taylor, Stan Srednyak, golang-nuts
You must like need to use WASI - but it doesn’t support mmap :(

> On Feb 17, 2023, at 2:37 PM, Ian Lance Taylor <ia...@golang.org> wrote:
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcX-2SgB%3Dq9bPKSxugfKD4-yTNFPUmSsF8zA5mdfzOrYrw%40mail.gmail.com.

Robert Engels

unread,
Feb 17, 2023, 3:46:16 PM2/17/23
to Ian Lance Taylor, Stan Srednyak, golang-nuts

On Feb 17, 2023, at 2:44 PM, Robert Engels <ren...@ix.netcom.com> wrote:

You must like need to use WASI - but it doesn’t support mmap :(
Reply all
Reply to author
Forward
0 new messages