wwama is a small Rust wrapper crate around a local llama.cpp checkout. It is intended to make the llama.cpp C API available to Rust code on native targets and browser-oriented WebAssembly targets, including both wasm32-unknown-unknown and wasm64-unknown-unknown.
The crate currently focuses on the lower-level pieces needed for embedding inference work:
- building
llama.cppas static libraries from Cargo; - exposing raw FFI bindings for the relevant
llama.hAPIs; - providing lightweight RAII wrappers for backend, model, context, and batch lifetimes;
- supporting WebGPU-enabled Emscripten builds for WebAssembly;
- avoiding
llama.cppexamples, tools, and server targets.
This is an early integration crate. It is useful as a buildable wrapper layer, but it is not yet a high-level embedding API. Callers are still responsible for model selection, tokenization/batching strategy, pooling configuration, and copying embedding vectors out of the returned llama.cpp buffers.
By default, wwama expects this layout:
wwama-projects/
llama.cpp/
wwama/
The default build.rs lookup uses ../llama.cpp. Override it with:
WWAMA_LLAMA_CPP_DIR=/path/to/llama.cpp cargo buildNative builds require:
- Rust 1.95 or newer;
- CMake;
- a C++ toolchain compatible with
llama.cpp.
WebAssembly builds require:
- the
wasm32-unknown-unknownRust target for wasm32 builds; rust-srcpluscargo -Zbuild-std=corefor wasm64 builds;- Emscripten SDK for building the
llama.cppC/C++ libraries; - EMDawnWebGPU when building with the default
webgpufeature.
The build script searches for Emscripten in this order:
WWAMA_EMSCRIPTEN_TOOLCHAIN_FILE;WWAMA_EMSDK;EMSDK;$HOME/emsdk;$HOME/Code/emsdk.
The build script searches for EMDawnWebGPU using WWAMA_EMDAWNWEBGPU_DIR first. Set it explicitly when building outside this workstation.
Native:
cargo buildWASM32 with WebGPU, using the default features:
rustup target add wasm32-unknown-unknown
cargo build --target wasm32-unknown-unknownWASM64 with WebGPU:
rustup component add rust-src
RUSTC_BOOTSTRAP=1 cargo build -Zbuild-std=core --target wasm64-unknown-unknownThe wasm64 target currently needs build-std because the toolchain does not ship prebuilt core for wasm64-unknown-unknown.
CPU-only WASM builds are available by disabling default features:
cargo build --no-default-features --target wasm32-unknown-unknown
RUSTC_BOOTSTRAP=1 cargo build -Zbuild-std=core --no-default-features --target wasm64-unknown-unknownwebgpuis enabled by default. For WebAssembly targets, it enablesGGML_WEBGPU=ONin thellama.cppCMake build.- Native builds currently compile the CPU path even when the feature is enabled.
Licensed under the Apache License, Version 2.0. See LICENSE.