#GHC s #wasm backend,native uses the native bignum backend and the wasm native #codegen Compared to the #gmp flavour, the run-time performance may be slightly worse if the workload involves big Integer operations. May be useful if you are compiling proprietary projects and have concerns about statically linking the #LGPL-licensed gmp library.
Besides wasm MVP, certain extensions are used. The feature flags are enabled globally in our wasi-sdk build, passed at GHC configure time, and the wasm NCG may make use of the features. The rationale of post-MVP wasm feature inclusion:
Non-browser non-JavaScript runtimes

wasmtime
wasmedge
toywasm
wasmi

Non-browser #JavaScript runtimes

node, using the builtin wasi module to provide WASI implementation
bun, using the builtin WASI implementation
deno, using a legacy WASI implementation in std
#browsers

WASI spec includes certain syscalls that are provided as the wasi_snapshot_preview1 wasm imports. Additionally, the current WASI ABI specifies two different kinds of WASI modules: commands and reactors.
When linking a program for almost any platform out there, the linker needs to handle ctors(constructors) & dtors(destructors). ctors and dtors are special functions that need to be invoked to correctly initialize/finalize certain runtime state. Even if the user program doesn't use ctors/dtors, as long as the program links to libc, ctors/dtors will need to be handled.

Add --export flag for malloc/free. You can now allocate and free linear memory buffers that can be visible to the Haskell world, since the entire linear memory is available as the memory export.
In the #Haskell world,
https://github.com/palas/ghc-wasm-meta

GitHub - palas/ghc-wasm-meta: Fork of `haskell-wasm/ghc-wasm-meta` (from here: https://gitlab.haskell.org/haskell-wasm/ghc-wasm-meta)

Fork of `haskell-wasm/ghc-wasm-meta` (from here: https://gitlab.haskell.org/haskell-wasm/ghc-wasm-meta) - palas/ghc-wasm-meta

GitHub

you can pass Ptr as foreign export argument/return values.
You can also use mallocBytes in Foreign.Marshal.Alloc to allocate buffers in the Haskell world. A buffer allocated by mallocBytes in Haskell can be passed to JavaScript and be freed by the exported free, and vice versa.

If you pass a buffer malloced in JavaScript into Haskell, before freeing that buffer after the exported Haskell function returns, look into the Haskell code and double check if that buffer is indeed fully consumed in Haskell! Otherwise, use-after-free bugs await.