Skip to main content

Crate llama_cpp_sys

Crate llama_cpp_sys 

Source
Expand description

Raw FFI bindings to llama.cpp, plus the first-party C++ shim (wrapper.cpp) that exposes the _c-suffixed symbols our Rust callers consume.

§Activation

The real bindings are hidden behind the bindings cargo feature. A default build (cargo build -p llama-cpp-sys) compiles this crate to an empty shell on every target — this keeps the workspace-wide cargo clippy / cargo check on Linux CI runners green, because llama.cpp’s cmake build requires a C++ toolchain and pulls in ~180 MB of source.

To get the actual FFI surface, build with --features bindings. The build script will use the in-tree vendor/llama-cpp directory if present, and otherwise clone the pinned commit b46812de78f8fbcb6cf0154947e8633ebc78d9ac from GitHub into $OUT_DIR.

§Safety and stability

This is a -sys crate: every item under [bindings] is unsafe extern "C" and mirrors the upstream C ABI (after the _c suffix introduced by wrapper.cpp) one-to-one. It is not meant to be consumed directly outside the workspace. The safe wrapper crate xybrid-llama owns the RAII, typed error mapping, and streaming-trampoline concerns.

The generated bindings are intentionally not re-exported transitively: downstream crates opt in explicitly by depending on llama-cpp-sys with the bindings feature and using the items behind [bindings].

§Phase note (epic: llamacpp-crate-split)

The extern declarations in [bindings] are generated by bindgen from wrapper.h, which declares the first-party _c shim surface consumed by xybrid-llama.

Functions§

backend_init
No-op stub when the bindings feature is disabled. Lets the wrapper crate’s LlamaCppBackend::new() constructor call backend_init() unconditionally without a #[cfg] branch.
backend_init_with_configure
No-op stub when the bindings feature is disabled.