https://kotlinlang.org logo
#webassembly
Title
# webassembly
o

Oleg Yukhnevich

03/02/2023, 9:30 AM
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

sdeleuze

03/02/2023, 9:38 AM
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

Oleg Yukhnevich

03/02/2023, 9:42 AM
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

sdeleuze

03/02/2023, 9:45 AM
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

Oleg Yukhnevich

03/02/2023, 9:50 AM
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

sdeleuze

03/02/2023, 9:50 AM
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

Oleg Yukhnevich

03/02/2023, 9:52 AM
hah, glad to hear that, thanks!
s

Svyatoslav Kuzmich [JB]

03/02/2023, 10:08 AM
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

Oleg Yukhnevich

03/02/2023, 10:15 AM
Okay I have several
Questions
in repository readme - I will convert them to YouTrack issues in coming days 🙂
m

Matt Nelson

03/02/2023, 10:24 AM
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

Oleg Yukhnevich

03/02/2023, 10:28 AM
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

Matt Nelson

03/02/2023, 10:30 AM
Ah I see what you're doing there.
25 Views