-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to compile Virgil into WASI #72
Comments
You can try this:
The generated |
Also a very worthwhile option is |
I was able to get it compiling, but not fully working (I guess because the file issue you commented). We can keep this issue open until Not sure if this may help or not, but usually when having WASI applications you may want to provide them with a |
I'd love to play a bit more on this. I got |
Hmm, that's weird. If I compile
This also works in |
This is a common practice in most server-side Wasm/WASI runtimes. I believe Wasmer, wasmtime, WasmEdge, and wasm3 all do that (this is, so the binary can recognize the program being run). This would imply that |
Done. I fixed the |
What remains is for me to fixup |
Thanks for the fix. I recompiled and I verified this actually works with wasm3 (via However, I can't get it to work with Wasmer or Wasmtime. I'm really not sure what's going on at first sight. I'm inclined to think it might be a small bug on the WASI impl in Virgil, since the behavior seen in Wasmer or Wasmtime is the same: no output. I assumed the first argument thing will fix it, but doesn't seem to be the case. I inspected the module and everything seems fine compared to other WASI modules that run properly in all runtimes.
Awesome, I'd really love to get it fully working! |
Oh, I noticed one small difference.
While the Wasm/WASI generated module (Aeneas.wasm), doesn't even import this function. |
Yeah, I noticed that |
Small update: I just tested the latest master with the commit you pointed @titzer, but it still doesn't work with wasmer or wasmtime. I'm now a bit confused on what's going on :/ |
I tried to take on the challenge again! Here's how to try it locally! git clone https://github.com/titzer/virgil.git
cd virgil
export VIRGIL_LOC=$(pwd)
export PATH=$PATH:$(pwd)/bin/:$(pwd)/bin/dev
# make sure that java is available in your path
v3c-wasi -shadow-stack-size=1m -heap-size=500m -output=/tmp */*.v3 $VIRGIL_LOC/lib/util/*.v3 \
$VIRGIL_LOC/lib/asm/x86-64/X86_64Assembler.v3 \
$VIRGIL_LOC/lib/asm/arm/ArmAssembler.v3 \
$VIRGIL_LOC/lib/asm/x86/X86Assembler.v3 \
$VIRGIL_LOC/lib/asm/mips/MipsAssembler.v3 The file is now being generated properly: However, I'm not sure how to run it with Wasmer, I'm trying the following but it doesn't work: git clone https://github.com/titzer/virgil.git
cd virgil
cd apps/HelloWorld
wasmer run /tmp/Aeneas.wasm --dir=. -- HelloWorld.v3 But it outputs:
Any hints on what I may be doing wrong @titzer ? |
I think that the problem is in |
I've been playing with the idea of getting compilers and new languages into the Wasm/WASI world, as I really think it enriches the ecosystem.
Zig has recently supported compiling to Wasm/WASI and I was wondering how we could get the self-hosting Virgil compiler into the WASI world.
I tried playing a bit with the
/bin/dev
bash files but I was unable to get Virgil compiling into WASI (the compiler itself).Any help will be greatly appreciated!
The text was updated successfully, but these errors were encountered: