Closed kulcsaradam closed 7 months ago
This patch should enable to compile c programs which use stdout with emcc to run from walrus.
Emcc compile flags: --no-entry
, -sEXPORTED_FUNCTIONS
, -sEXPORTED_RUNTIME_METHODS
and Walrus --run-export
flag should be used.
-sEXPORTED_FUNCTIONS
and at least one function ran by --run-export
should be the same.
See test/wasi/hello_world.c
for example on how to compile and run.
I wonder that we need to add --run-export
flag to run a c program compiled with emcc.
Other WASM engines can just run the compiled wasm files without any options (--no-entry
flag is not required either).
I think that it is possible to directly start running the main
function in c program using wasi.
What do you think about this?
Both of you are right. After reading the documentation through more carefully I came up on this:
https://github.com/WebAssembly/WASI/blob/main/legacy/application-abi.md
By default environments should run the _start
function if the user does not select any function to run.
I will be implementing this and then update the patch.
I have changed it so that executeWASM
start a _start
function by default.
I have also found out that by doing this, if wast
files have a _start
function they will be ran by the Shell
and then we started to wonder if we should seperate the running of wast and wasm files somehow?
I looked at some other runtimes and for example, wasmer
completely seperates the running and parsing of those two types of files by different methods. I can make an issue if you would like to move on with this.
Also I have updated wasi.cmake
so that it doesnt spam messages when building on Windows.
Rebased to latest patch.
I found a bug that was accidentally left in. Fixed it before the pr is merged. Latest branch should be ready for merge.
Rebased to latest patch.
Change runExports so that wasi imports can be used. Improve fd_write so that emscipten compiled programs can be used. Also add example programs.