3 ms·
As somebody familiar with WebAssembly, how would you do FFI? like say you wanted to make a J2534 DLL http://www.drewtech.com/support/passthru.html http://www.d
by MuffinFlavored 5y ago
As somebody familiar with WebAssembly, how would you do FFI?
like say you wanted to make a J2534 DLL http://www.drewtech.com/support/passthru.html http://www.drewtech.com/support/passthru.html
How would you export these DLL functions or even call functions from other DLLs (dlopen/dlsym, etc.)
- gary_0 5y agoYou can import host functions and data to a WASM VM much like you would with, say, an embedded Python VM. The exact API depends on which VM implementation and host language you're using. dlopen/dlsym support is still in the works (for example, see [0]). You can't call function pointers directly from WASM, naturally, but it is possible to wrap dlsym so you can use it from a WASM program. There just isn't a standardized/pre-made way to do it yet, so you'd have to write the glue code yourself. [edit] The Emscripten WASM toolchain seems to support dlopen/dlsym, see: https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md https://github.com/WebAssembly/tool-conventions/blob/main/Dy... [0] https://github.com/wasmerio/wasmer/issues/1995 https://github.com/wasmerio/wasmer/issues/1995
- bluejekyll 5y agoYou may want to look into WASM interface types, which is defining what amounts to an IDL for WASM so that different languages have common calling conventions: https://hacks.mozilla.org/2019/08/webassembly-interface-types/ https://hacks.mozilla.org/2019/08/webassembly-interface-type... I don’t know if there’s a better intro article. I believe this is the current iteration of the proposal: https://github.com/WebAssembly/interface-types/blob/main/proposals/interface-types/Explainer.md https://github.com/WebAssembly/interface-types/blob/main/pro...