graalvm

Adam Helins 2023-01-09T22:39:26.019729Z

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)

phronmophobic 2023-01-23T19:23:45.640629Z

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.

borkdude 2023-01-23T19:42:47.434789Z

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

phronmophobic 2023-01-23T19:49:40.289829Z

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.

phronmophobic 2023-01-23T19:53:50.903409Z

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.

phronmophobic 2023-01-23T19:55:29.902199Z

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)

borkdude 2023-01-23T19:55:48.741879Z

ah

borkdude 2023-01-23T19:56:20.854629Z

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

phronmophobic 2023-01-23T19:57:35.873799Z

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.

borkdude 2023-01-23T20:01:06.057709Z

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

phronmophobic 2023-01-23T20:02:19.891919Z

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

borkdude 2023-01-23T20:02:30.755469Z

similar to pods

phronmophobic 2023-01-23T20:11:41.212359Z

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.

phronmophobic 2023-01-23T20:12:41.567969Z

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

borkdude 2023-01-23T20:13:34.781949Z

interesting

Adam Helins 2023-01-25T12:43:39.230109Z

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