llm icon indicating copy to clipboard operation
llm copied to clipboard

Consider removing the `bindgen` dependency

Open philpax opened this issue 2 years ago • 4 comments

#22 and #24 show that clang is required as a build dependency because bindgen uses it to read in ggml.h and produce bindings. We should consider just writing the C bindings ourselves - it shouldn't be too difficult as long as we account for the idiosyncrasies (like #6)

philpax avatar Mar 16 '23 13:03 philpax

Would it be possible to use bindgen as a dev dependency and just push the generated code?

Manually maintaining C bindings sounds very tedious :sweat_smile:

setzer22 avatar Mar 16 '23 14:03 setzer22

Possibly - not sure if there are any concerns with architecture-specific behaviour that would get baked in. Maintaining the bindings ourselves lets us handle that.

Maintaining the C bindings would be tedious, but I can't imagine that ggml's interface will change much over time. We'd have the initial pain, and then we'd have to add or remove a few lines every so often - shouldn't be too bad!

philpax avatar Mar 16 '23 14:03 philpax

Hmmm, good point. But one thing that concerns me a bit with doing this manually is that if we mistype something in the bindings, or forget to update something, and then call a function with an incorrect signature, that's UB. Isn't it?

setzer22 avatar Mar 16 '23 14:03 setzer22

It can be - I hope that doesn't happen, but it's definitely a possibility. We don't depend on too much from ggml as it is now anyway, right?

philpax avatar Mar 16 '23 16:03 philpax