dotnet-webassembly icon indicating copy to clipboard operation
dotnet-webassembly copied to clipboard

WASM module (attached) that works in browsers throws an error from dotnet-webassembly

Open ThunderousEcho opened this issue 2 years ago • 4 comments

Error from dotnet-webassembly: ModuleLoadException: At offset 525: Unrecognized section type 12. WebAssembly.Runtime.Compile.FromBinary (WebAssembly.Reader reader, WebAssembly.Runtime.CompilerConfiguration configuration, System.Type instanceContainer, System.Type exportContainer) (at /_/WebAssembly/Runtime/Compile.cs:505) WebAssembly.Runtime.Compile.FromBinary[TExports] (System.IO.Stream input, WebAssembly.Runtime.CompilerConfiguration configuration) (at /_/WebAssembly/Runtime/Compile.cs:105) WebAssembly.Runtime.Compile.FromBinary[TExports] (System.IO.Stream input) (at /_/WebAssembly/Runtime/Compile.cs:83) non-working in dotnet-webassembly.zip

Note that I'm running this from inside Unity dotnet-webassembly version 1.2.1 WASM module generated with tinygo

Thanks in advance for any help

ThunderousEcho avatar Mar 03 '23 21:03 ThunderousEcho

Whatever "section type 12" is, it must be a relatively recent addition to the WASM spec. I'll look into this when I have time.

RyanLamansky avatar Mar 11 '23 18:03 RyanLamansky

Looks like this library doesn't implement the Bulk Memory Operations proposal, which introduces section 12 as an optional section that describes the number of data segments in the module: https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md

chutchinson avatar Apr 20 '23 07:04 chutchinson

I spent some time on this today and although adding support for the DataCount section is easy, it's only the first problem: your WASM also uses new instructions. Those will need to be implemented, too, for compilation to work.

RyanLamansky avatar Jun 17 '23 14:06 RyanLamansky

Thanks for looking into this

ThunderousEcho avatar Jun 17 '23 16:06 ThunderousEcho