ffi loads unused function symbols
Using dt-ffi/define-library-interface waits to load function symbols until runtime (this is good), but once a function is called, all of the symbols for the library are loaded and any missing symbol is an error. I think a case can be made that this is the desired behavior, but I've come to prefer only requiring symbols to exist for functions that are actually called.
One illustrative example is for ggml, a library that offers numerical tensor operations for various backends like CPU, metal, and CUDA. ggml has generic functions that work across all backend as well as functions that are specific to particular backends. My preferred setup is to generically define the library interface via clong and use the backend specific functions depending on information collected at runtime. Knowing which backends are available may require calls to ggml.
Also, for many wrapper libraries, I allow for users to compile the native library themself so that they can enable/disable certain build time flags. This makes it awkward to wrap functions that may only be available for certain environments.
100% agree! Should be a straightforward fix will do as soon as possible.
Hmm - that is a side effect of direct binding I think which is a significant JNA performance improvement. Perhaps we need one jna library class per function to get this sort of lazy property.
A work around for now would be to partition optional code into its own library interface and have you user initialize! pass the loaded library into the optional interfaces.
I don't have any particular use case that needs this feature right now. It would be convenient to have during development, but it's not a big deal.
Hmm - that is a side effect of direct binding I think which is a significant JNA performance improvement.
This seems worth partitioning any optional code. Maybe this is worth waiting to revisit once panama gains wider adoption.