I have some questions about WASM interop: 1. Will ...
# webassembly
I have some questions about WASM interop: 1. Will K/W eventually support having bi-directional WASM module interop ( https://developers.google.com/web/updates/2018/03/emscripting-a-c-library )? 2. Are WASM Interface Types separate from WASM modules? 3. With C libraries (eg LVGL: https://lvgl.io/ ) would WASM modules be the way to go with WASM interop for K/W? 4. What is next on the K/W roadmap for WASM interop? 5. Are there any future plans to provide a viable path for porting K/N libraries (that act as a Kotlin binding to a C library) to K/W?
There is some confusion on what the differences are between C lib interop, and WASM Interface Types interop, IF K/W's WASM interop expands to include these options.
Wasm modules are too low-level to be consumed at compile time directly. You would need some high-level metadata additionally. This can be .h header file for C ABI, .d.ts file for JS API, or adapter module for Interface Types. I think we will want to support for C ABI (and IT) in the future, but initially we are focused on JS interop. It would make sense to make it as compatible to K/N as possible, but we haven’t looked at it closely yet.
1. I’m not sure about bidirectional C interop, maybe. No concrete plans. 2. They are different layers. 3. You would want a wasm object file + header file. 4. No concrete plans for interoperation with other languages compiled to Wasm at the moment. 5. Not yet.
👍 2
What does a WASM object file look like, and how does it differ from a C object file?
I get the impression with the WASM object file + header file system that the C interop process (with generating the mapping files) would be extremely similar to how K/N does it, but the linking process would be completely different. If my understanding is correct, the header files provide the interop metadata to generate the mapping files, and the WASM object files provide the linking metadata to generate the WASM module (roughly equivalent to an ELF file). 🤔
This is what I am referring to with the C interop (also covers how manual memory management works alongside K/N's GC based memory model): https://kotlinlang.org/docs/native-c-interop.html
Wasm object files are a convention similar to native object files: https://github.com/WebAssembly/tool-conventions/blob/main/Linking.md
🆗 1