Kagami / vmsg

:musical_note: Library for creating voice messages
https://kagami.github.io/vmsg/
Creative Commons Zero v1.0 Universal
348 stars 58 forks source link

How to recompile vmsg.wasm? #64

Open lucivpav opened 3 years ago

lucivpav commented 3 years ago

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?

s1239u85 commented 1 year ago

Exact same issue here.

NegiBaba commented 1 year ago

I have tried recompiling the vmsg.wasm as well by following all the steps as said in the readme. So the we require the LLVM_ROOT when we are manually building from source, for anyone who's new to it can check emscripten_configuration link. Anyone can easily configure the LLVM_ROOT var. there. Now for the next issue if we try to

make clean all

the first issue we get is something related emscripten_memcpy_big and we get the help in the console it self. We receive two ways we can move forward one is to force ignore the errors and second one is to include this in EXPORTED_FUNCTIONS but both of these ways gives us error when trying to record in the local dev server(the same issue as above that module is not an object) I have tried several things as well but writing those here doesn't make any sense. So until and unless someone who's expert in web assembly looks at this issue, we are most probably going to resolve this by ourselves.