Skip to content

How to recompile vmsg.wasm? #64

@lucivpav

Description

@lucivpav

I have downloaded Emscripten SDK, downloaded the latest and activated it.

Not sure what

fix LLVM_ROOT variable of Emscripten config

means.

When make clean all finishes successfully, the generated vmsg.wasm contains the following imports:

Import[2]:
 - func[0] sig=10 <a.a> <- a.a // aka env.exit
 - func[1] sig=1 <a.b> <- a.b // aka env.emscripten_resize_heap

which is not compatible with the imports specified in vmsg.js:

{
         memory: memory,
         pow: Math.pow,
         exit: exit,
         powf: Math.pow,
         exp: Math.exp,
         sqrtf: Math.sqrt,
         cos: Math.cos,
         log: Math.log,
         sin: Math.sin,
         sbrk: sbrk,
};

As a result, trying to run a project with the recompiled vmsg.wasm throws an error TypeError: WebAssembly.instantiate(): Import #0 module="a" error: module is not an object or function
I am guessing that the vmsg.js should be also regenerated using the Emscripten SDK. However, simply using the _vmsg.js in place of vmsg.js does not work - it causes other issues. It seems that vmsg.js has vmsg specific logic, that is not generated in _vmsg.js.

I tried to update the env object in vmsg.js to match the needs of the generated _vmsg.wasm, that is, to:

{
      "exit": _exit,
      "emscripten_resize_heap": _emscripten_resize_heap,
}

However, the implementation of _emscripten_resize_heap is dependent on a lot of generated logic/variables, that I find very hard to take and include in the original vmsg.js file.

Any advice on how to proceed with building this project?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions