Plugins — C ABI, plugin.zzi, native hooks
ZZ plugins speak C ABI (plugin.zzi). Rust crates can back plugins, but the ZZ
side never exposes Rust semantics. Use for unsafe, zero-cost abstractions,
no_std/embedded, manual layout — everything ZZ deliberately omits.
Minimal shape
Section titled “Minimal shape”my-plugin/ plugin.zzi # interface: func signatures ZZ sees src/lib.rs # or .c — C ABI exports zz.toml # [native] build hook (see below)import mypluginprintln(myplugin.fast_hash("hi"))Build hooks
Section titled “Build hooks”Prefer [native.build-cc]; bare [native] build = "<hook>" is deprecated
(build warns with a migrate hint pointing at docs/plugin-author-guide.md §4).
Export the ABI version stamp or the loader errors with a pointer to §11.
[native.build-cc]# cc + args to compile the plugin for the current target--allow-source-builds / --allow-hooks gate source builds in zz build and
AOT zz test (same meaning both places).
Authoring checklist
Section titled “Authoring checklist”- Keep the
plugin.zzisurface narrow and total — fallible ops returnResult<_, str>withplugin:op:code: detail. - Deep-copy at the boundary (ZZ values are CoW; never retain a borrowed pointer).
- Mirror VM and AOT semantics exactly; add a fixture under
tests/fixtures/and register ine2e.rs+dual_engine_parity.rs(+batch_lists.rsorEXCLUDEDwith reason) per Parity. - Document thread-safety: arenas are thread-local, string refcounts + intern
table are thread-safe; your global state must be too for
task.spawncallers. - Ship
DOCS.mdordocs/**/*.mdsozz info/publishbundle it.
Full guides: plugin-author-guide.md, writing-native-plugins.md.