Error when attempting to load WASM libraries.

Hello again! I have compiled a library with Cheerp to use in a project that uses CheerpJ. I initialize CheerpJ to use my compiled WASM library, libopenal.bc, whenever a program needs libopenal.so. However, whenever it gets opened loaded, two messages appear in the console saying Wasm: Unimplemented c0 - 3, and then it enters the Javascript debugger. Any attempts to unpause the debugger just returns back to the same spot. What might I be doing wrong that would be the issue? I used the latest commits of the Cheerp toolchain, and I'm using version 4.2 of CheerpJ.
11 Replies
lea
leaOP7d ago
I have discovered it to be an LLVM bitcode file. However, I am unsure how to compile this into a WASM binary.
apignotti
apignotti7d ago
CheerpJ requires shared WASM modules, which are supported by Cheerp as an internal experiment. The command line options are not public and not documented at this time and will most likely change in the future. As a completely unsupported guideline, something like this could work, but again please understand that we cannot provide full guidance on unsupported features.
/bin/clang++ -target cheerp-wasi-wasm -o library.wasm library.bc -cheerp-wasm-enable=exportedtable -cheerp-wasm-disable=globalization,unalignedmem -shared -pthread
/bin/clang++ -target cheerp-wasi-wasm -o library.wasm library.bc -cheerp-wasm-enable=exportedtable -cheerp-wasm-disable=globalization,unalignedmem -shared -pthread
lea
leaOP7d ago
Understood. Once I can get /opt/cheerp/bin/llc to not have a segmentation fault, I'll give it a shot. Thank you.
apignotti
apignotti7d ago
This assumes using nightly builds of Cheerp as well, I should have made it clear
lea
leaOP7d ago
Is the nightly version different from the latest commits?
apignotti
apignotti7d ago
It would be from a few commits ago, but these feature has been already part of Cheerp for quite a while. It's not part of the stable, but very old, 3.0 release.
lea
leaOP7d ago
Understood. I'll try to get llc to not crash so that I can attempt to convert it into a shared WASM module. Since the llc crash mentions CheerpWritePass, I'll switch to the compiler commit a7c26f5, which is right before a commit that modified CheerpWritePass.cpp.
apignotti
apignotti7d ago
No, that is not correct. The actual problem is that the library was build for the genericjs target, rather that the Wasm target It goes without saying that Wasm shared modules are generated by the Wasm target You need to compile the library itself for target cheerp-wasi-wasm
lea
leaOP6d ago
I see. I assume there is a cmake toolchain file for WASI, so I will do that in a bit. I can confirm that the library successfully compiled into a WASM binary. However, I now get an error saying Missing import: environ_sizes_get. Definitely made it further. I am aware this is an import WASI depends on.
apignotti
apignotti6d ago
As I mentioned before, getting wasm libraries to work with CheerpJ also require linking against a CheerpJ-specific library that is not currently released. There is no immediate workaround that I can suggest here. We do plan to release the required headers and libraries, but it's not something that we can prioritize in the short term
lea
leaOP6d ago
I was aware of that, but I was hoping it wouldn't extend to WASI. It makes sense though. At least I will have the code for when the libraries do get released. Thank you for the support, I will be saving this information for future use.

Did you find this page helpful?