Fork me on GitHub
#graalvm
<
2023-01-09
>
Adam Helins22:01:26

Do you know about a good file / dir watcher that supports native-image? I see https://github.com/nextjournal/beholder uses JNA on macos (which is not supported)

phronmophobic19:01:45

This link that graalvm posted today seems to indicate that JNA has been community tested, https://www.graalvm.org/native-image/libraries-and-frameworks/. I haven't JNA myself, but it would be great if it worked out the box with native-image.

borkdude19:01:47

@U7RJTCH6J Would you consider JNA to be more dynamic, e.g. suited to be used in bb scripts for example?

phronmophobic19:01:40

I think so. I think you could do most ffi calls at runtime as long as JNA is supported. I'm not sure you could make ffi calls with struct args or return values though.

phronmophobic19:01:50

The best fit might still be a custom libffi wrapper so that bb scripts could support structs by value. You might also be able to better control how it affects binary size.

phronmophobic19:01:29

There might also be a way to package runtime support for structs by value with JNA (since JNA uses libffi under the hood and libffi does support runtime structs by value)

borkdude19:01:20

using libffi directly might be interesting. the last POC you did added quite some size to bb though

phronmophobic19:01:35

right, but in theory, you could strip other packaged libs out of bb and offer them a la carte via ffi for an overall smaller bb.

borkdude20:01:06

wasn't there also a restriction of not being able to pass functions over the FFI border?

phronmophobic20:01:19

oh, right. you would be restricted to passing values that can be serialized

borkdude20:01:30

similar to pods

phronmophobic20:01:41

I was wondering why libffi added so much to the size of the binary. Looking at my code, I just realized that it might be because I'm pulling in dtype next to make the ffi calls. I wonder if it would make a difference if I generated the ffi calls using https://github.com/phronmophobic/clong.

phronmophobic20:01:41

clong let's you do the generation ahead of time and doesn't need to be included at runtime.

borkdude20:01:34

interesting

Adam Helins12:01:39

That's really cool, my last attempt at using JNA in a native image was a disaster

phronmophobic19:01:45

This link that graalvm posted today seems to indicate that JNA has been community tested, https://www.graalvm.org/native-image/libraries-and-frameworks/. I haven't JNA myself, but it would be great if it worked out the box with native-image.