Closed weijiekoh closed 3 years ago
Hello,
This error is raised by wasmparser
:
We use wasmparser
to validate the Wasm module before compiling it. It is raised by the Validator::data_section
. It seems that your Wasm module contains too much data segments. The maximum data segments is defined by the MAX_WASM_DATA_SEGMENTS
constant:
Its value is 100_000
at the time of writing.
That's quite a lot of data segments :-p. How did you generate the Wasm module?
I tried to run wasm-opt
to see if I can ameliorate things, but I get this warning:
$ wasm-opt -O3 a.wasm -o a.opt.wasm
Some VMs may not accept this binary because it has a large number of data segments. Run the limit-segments pass to merge segments.
And I get the same validation error with a.opt.wasm
.
Thank you so much for diving into this issue!
I see that it's a hardcoded constant. Would the team be interested if I submitted a PR that would make the maximum data segments a CLI config option?
I generated the WASM file using the circom
tool: https://github.com/iden3/circom. The context is that I'm writing a pretty large zero knowledge circuit using the circom language. To generate proofs for this circuit, we need to generate a witness file. The WASM file does exactly this.
Anyway, I've worked around this problem by generating the witness a different way (namely by using C++ code that circom
produces). It would, however, be nice if wasmer could do this too.
Yeah sure, try to submit a patch to the bytecodealliance/wasm-tools, and link this issue please :-).
I'm closing this issue since it's not related to Wasmer itself :-).
Thanks! I'll ping again if/when the patch is done :D
Summary
I have a WASM file that's 9.7M large, and
wasmer run
emits this error no matter which combination of compiler and engine I use:The WASM file is here: https://www.dropbox.com/s/fl0k41nsj3zjtad/processMessages_test.wasm?dl=0
Any help would be greatly appreciated! Thank you!