Closed Andre-LA closed 1 year ago
As discussed on Discord, the issue is that Emscripten manages it's own memory while the library is compiled with it's own allocator. If this https://github.com/fubark/cyber/blob/15df569aaeb54d33590854c56fa44826769191b3/src/lib.zig#L32 is changed to alloc = std.heap.c_allocator;
it should work. I guess we can also add a build option for this too.
As discussed on discord, with the latest changes, alongside with the change of wasm_allocator
to c_allocator
on the cited line, the runtime works on emscripten without any problems.
Hello, I'm trying to run Cyber on the web using emscripten (because of the SDL2 port), however, I getting an runtime error on the process.
Environment
Steps to reproduce
cyber.wasm.o
file using the commandemar -rcs libcyber.a zig-out/lib/cyber.wasm.o
.examples/c-embedded/main.c
.main.c
withemcc
with the commandemcc main.c ./libcyber.a -I./src/ -L. -o build/main.html
cd build/ && emrun main.html
.Expected behaviour
The expected behaviour would be seeing this message on the page's console:
Observed behaviour
An exception it's thrown, with a stack trace available on the browser's console, on the page's console only
creating Cyber VM
it's shown, which means that the problem happens oncyVmCreate
function call.Testing code
main.c:
Extra note
The code above works with wasmtime, when using the wasi-sdk with the same cyber build, with (almost) same building steps.