wasm-micro-runtime
wasm-micro-runtime copied to clipboard
iwasm: WASM module load failed: struct or array as field is not supported in constant expr
Steps to reproduce
- Unpack zip kotlin-wasm-wasi-example-wasm-wasi-prod.wasm.zip
- Build
iwasmwith the following command
cmake .. -DWAMR_BUILD_GC=1 -DWAMR_BUILD_BULK_MEMORY=1 -DWAMR_BUILD_EXCE_HANDLING=1 -DWAMR_BUILD_TAIL_CALL=1 -DWAMR_BUILD_CUSTOM_NAME_SECTION=1 -DWAMR_BUILD_EXCE_HANDLING=0 && make
- Run
./iwasm kotlin-wasm-wasi-example-wasm-wasi-prod.wasm
Expected behavior
It should print something like:
Hello from Kotlin via WASI
Current 'realtime' timestamp is: 1715281633864118000
Current 'monotonic' timestamp is: 210424654558083
Actual behavior
It prints:
iwasm: WASM module load failed: struct or array as field is not supported in constant expr
I took a look at this case, it's due to the current implement limitation, we don't allow to init the global with references. The #3411 is also due to this limitation.
Any chance they will be fixed in the foreseeable future?
We plan to take on that and will try our best to support this syntax, it could be a while through
@bashor I submitted PR #3447, and now it should be able to run this case successfully in interpreter mode. But it only supports the nested constant initializer expression like struct.new struct.new (a struct's field is a struct), ref.func struct.new (a struct's field is a func obj). Just want to know is there requirement from you like array.new struct.new (a struct's field is an array), struct.new array.new (an array's element is a struct)? If yes, is there any case from you? Thanks.
@wenyongh Hi! Thanks for the fix! Could you please also check it on #3411? It's an unoptimized version and should contain more cases.
@bashor Welcome, I looked into this case and fixed several issues in wasm loader, now iwasm can run this case successfully, please try PR #3447 again.