Hey, just in case I was able to link native librar...
# webassembly
o
Hey, just in case I was able to link native library to WASM/JS in scope of https://kotlinlang.slack.com/archives/C0BJ0GTE2/p1677748948814649 There a lot of hacks of course, but still, it works. For now only on nodejs, but I will try to add browser/wasi there also. Thanks for working on WASM and on
wasm
support in
skiko
, which helped me a lot 🙂 Is there any plans for allowing to somehow distribute, or easier link to external
wasm
binaries?
👍 3
s
IMO easy distribution and linking of Wasm files should happen middle term via Wasm Component Model and warg repositories. Higher performance cinterrop style should be possible for specific needs, but will be IMO more involved.
o
Overall yes, but what if someone will want to use some internal native library, like in skiko There is no reason to publish it somewhere else, but just embed somehow into kotlin library published to maven central
s
I guess some cinterop style tooling working for Kotlin/Wasm would make sense for this kind of use case.
Mainly to avoid copying memory too much.
But for dynamic linking of Wasm files, IMO Wasm Component Model is the way to go for a wide range of reasons.
I will have a deeper look to what you did, thanks for sharing BTW.
o
I agree that component model is just perfect and will help a lot, we just not here yet, so I’ve done what is possible right now with current K/WASM 🙂
s
Yep, thanks for that 🙂
I was planning to experiment on leveraging Rust and C libraries without Component Model next week so your work arrive at a perfect timing.
I will share feedback.
o
hah, glad to hear that, thanks!
s
I was able to link native library to WASM/JS
Awesome!
Is there any plans for allowing to somehow distribute, or easier link to external
wasm
binaries?
We want to improve this area, but we don’t have a concrete design yet. Feel free to report an issue to YouTrack with your use case.
o
Okay I have several
Questions
in repository readme - I will convert them to YouTrack issues in coming days 🙂
m
Just quickly looking at your lib. You are using
Random
which is not providing cryptographically secure random numbers, which anything built atop of will be borked 😢 . See https://github.com/05nelsonm/secure-random
o
as far as I remember, there is no usage of any
Random
at all in
ffi-kotlin
🙂 On the other side, secure random is provided in https://github.com/whyoleg/cryptography-kotlin (but it’s another library)
m
Ah I see what you're doing there.