Conversation
|
I like this change a lot. I originally selected build-time bindgen because it seemed to be what the community did in general. Can you point to other projects who do something like this? |
|
I'm aware of a few, though it's not a very widely used pattern (to my great disappointment):
I've been thinking about for years to work on |
|
I guess in some sense, this is also an experiment, to get a feel for how much is needed for This actually currently fails on Windows, for two reasons: First, enums with no zero members default to being And second, this definition of Bindgen successfully picks up the |
|
So I'm going to mark this as a draft, and continue it after fixing stuff in |
Currently, the sys APIs include the entire definition of `FILE`, which is platform-dependent and introduces a lot of extra types to declare. Instead, we define `FILE` as `c_void`, and exclude the extra definitions.
This makes users builds faster, as they don't have to build bindgen and all of its dependencies, and makes it easier for maintainers to see and track changes to the sys API. One downside is that you have to manually update the bindings if you've made a local change to e.g. llama.h, but the process for doing so should be fairly simple (just run `cargo run --bin generate-bindings`).
This has several benefits:
bindgenand all of its dependencies.libclanginstalled, only maintainers do.llama-cpp-sys-2API.And a few downsides:
include/llama.h.cargo run --bin generate-bindings).llama.cppever adds#ifdef-gated APIs, this will be a bit more work to maintain (we'd probably need to blacklist those, and add their definitions manually).llama.cppcould add#ifdef ANDROID int foo() #else char foo() #endif, and that'd be unsound. They haven't done crazy things like that so far though, so this probably isn't going to be an issue.I've manually verified that the bindings are the same across both Android and macOS, and CI should continually verify that they're the same across the major desktop targets.