hey there
I am working on a toy language and I was wondering if it would make sense for me to use WASI + WAMR as a compiler backend and get AOT binaries as output? I was thinking of this chain;
compiler frontend > wat files as the IR > wat2wasm to generate wasm > wamr to compile
does that approach makes sense?
Few more questions, as I am very new to the webassembly area;
Note: I would prefer not to use cranelift as I am not comfortable with rust and would prefer c99 instead.
Hi,
yes, normally you can use WASI + WAMR as a compiler backend as long as the input is a well-formed wasm file and it compiles with the proposal of wasi snapshot preview1:
https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md
And maybe you can refer to the output wasm file compiled by wasi-sdk or emsdk.
And there is a similar project which compiles typescript into wasm, and then uses WAMR to run the wasm file:
https://github.com/intel/Wasmnizer-ts
Note that it uses binaryen to emit the wasm bytecodes. And now it only supports interpreter mode, since the AOT mode requires WAMR GC AOT feature which is under development.
For some questions:
Per our understanding, normally the linear memory is divided into three areas: data area, aux stack area (or shadow stack) and heap area, the __data_end
and __heap_base
globals can be exported to mark them. Refer to:
https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/doc/memory_tune.md
WAMR runtime doesn't support loading .dll/.so files yet.
Do you mean calling libc APIs from wasm application? It is supported if the wasm file imports the wasi APIs. And WAMR also supports the libc-builtin APIs to support a subset of libc, in which file/socket operations are not supported. Refer to here for a list of supported libc APIs:
https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c#L989-L1041
Last updated: Nov 22 2024 at 17:03 UTC