Skip to content

ffi loads unused function symbols #122

@phronmophobic

Description

@phronmophobic

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions