buzz icon indicating copy to clipboard operation
buzz copied to clipboard

wasm web/wasi target

Open giann opened this issue 2 years ago • 7 comments

Probable issues:

  • External lib (maybe wasm build exists for some?): libpcre, mimalloc (can be turned of -Duse_mimalloc=false)
  • VM tail call not supported: the VM does not uses a big switch to dispatch opcode but tailcalls, this does not seem to be supported by llvm_stage2 for the wasm64-wasi target
  • JIT must be turned off (-Djit=false)
  • Targeting wasm32 would require NaN boxing to operate on a u32 rather than a u64
  • std.DynLib has no implementation for wasm
    • That would require std libs to not be built as shared libraries but bundled with buzz exe

giann avatar Jul 11 '23 14:07 giann

Are there any plans for compiling buzz to wasm directly? Assuming this ticket is to just allow the buzz interpreter to run within wasm?

judah-caruso avatar Sep 25 '23 04:09 judah-caruso

Not sure what you mean? buzz can only run within wasm if built for wasm.

giann avatar Sep 25 '23 05:09 giann

Ah sorry, I meant creating something like a new RunFlavor that compiles buzz to wasm (similar to assemblyscript).

For example:

// main.buzz
import "std";

fun main([str] _) > void {
	print("hello, world");
}
$ buzz -target=wasi_wasm32 -out=main.wasm main.buzz
$ wasmer main.wasm # hello world

This is most likely out of scope for the project, but I was just curious if this is a plan for the future.

judah-caruso avatar Sep 25 '23 14:09 judah-caruso

Yes this is out of scope. That would require buzz to become an AOT compiled language.

giann avatar Sep 25 '23 15:09 giann

Reopening because of https://ziglang.org/download/0.12.0/release-notes.html#Bring-Your-Own-OS-API-Layer-Regressed which effectively kills this feature

giann avatar May 16 '24 07:05 giann