Open gmlewis opened 4 months ago
This is due to the fact that we would like to print some debug information when the program fails (abort('xxx')
), and there's no uniform way to do the output in the Wasm world. We are working on this right now. For example, we are providing panic()
that also aborts the program but do not log the error message.
@bhelx or @nilslice - do you have any recommendations for a more standardized way for languages to provide debug information that wouldn't require mangling the WAT output before creating the final WASM?
Or do you know of examples for how other languages get around this issue?
I see, thanks!
I know at least AssemblyScript has a flag for the compiler to set the function you want to use, and the assemblyScript PDK provides a similar abort function implementation. e.g.
npx asc example.ts --outFile example.wasm --use abort=example/myAbort
I don't know if that's possible here though without the feature being added to the moonbit compiler.
I know at least AssemblyScript has a flag for the compiler to set the function you want to use, and the assemblyScript PDK provides a similar abort function implementation. e.g.
npx asc example.ts --outFile example.wasm --use abort=example/myAbort
Yeah, we'll try to support a similar behavior. For the first step though (probably next week's release), we'll replace the abort
with panic
, so that we do not rely on spectest.print_char
unless the user uses println
explicitly. Then we'll try to improve the behavior.
@peter-jerry-ye can we do it for this week's release?
Thank you for considering making it configurable! I think it will make moonbit more portable.
@gmlewis It should have been disabled in yesterday's release. Please check it again.
I'm trying to build an Extism PDK for MoonBit here: https://github.com/gmlewis/moonbit-pdk and the resulting wasm binaries always include this reference (converted to WAT):
The Extism Host does not provide the function
spectest.print_char
, so I need to be able to disable it or override/replace it with another function within my package/library.Here are examples of the resulting builds (using
moon build --target wasm
):greet.wasm
: https://modsurfer.dylibso.com/module?hash=3fc57ca997006043ee3451257c13795bfa84186bc9fe00e7d77a471cea04b71acount-vowels.wasm
: https://modsurfer.dylibso.com/module?hash=98d020447ea59fda8f1721df17f6173add472ffc785c53757fe1ffd00d7065d0