Repository navigation
abi: verify public declarations against the Rust FFI - #115
Merged
Merged
Conversation
Add a check-abi target that generates declarations from the production Rust FFI with pinned cbindgen and compares them with the hand-written header using clang ASTs and record layouts. It checks extern function names, return types, ordered arguments, pointer indirection, callback signatures, public struct layout and enum values, with narrow exceptions for checked c_int inputs and read-only result views. Run the check on the shared Ubuntu CI build and include temporary signature and layout drift fixtures so a parser or comparison regression is visible. Refs #99
LanceDBIndexStatistics exposes borrowed const C strings while Rust keeps the owned pointers private for Drop, the same deliberate const view already recorded for LanceDBIndexInfo. The object layout and calling ABI are unchanged.
Run the declaration check against the host and the Windows MSVC LLP64 Clang target so LP64-equivalent spellings cannot hide an LLP64 ABI break. The target check uses Clang resource headers and a temporary empty stdlib.h shim, without building a Windows Rust library. Compare enumerator names as well as values, canonicalizing Rust variant names to the public LANCEDB_* spelling while ignoring declaration order. Make every checked c_int allowance name its expected C enum, including the #103 create-index API, and reject a wrong enum. Prove the layout comparison independently with an _Alignas-only fixture and require the exact offset diagnostic. Add a long-return fixture that passes on LP64 and fails on LLP64.
This was referenced Nov 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
check-abitarget, run on the shared Ubuntu CI build, that generates declarations from the production Rust FFI with pinned cbindgen 0.29.4 and compares them withinclude/lancedb.hthrough clang ASTs and record layouts.The comparison covers every
#[no_mangle] extern "C"export, function return types, ordered arguments, pointer indirection, callback signatures, public by-value struct field types/order/offsets/size/alignment, and public enumerator names and values. Opaque handles are compared by identity; header-onlystatic inlinehelpers are excluded. Enumerator order is ignored, while the CLANCEDB_*names are checked against the canonical names of the Rust variants.The check runs for the host data model and for the Windows MSVC LLP64 Clang target using Clang resource headers. The target check does not build a Windows Rust library. Deliberate differences remain narrow and named:
c_intinputs where the header exposes a specific C enum (fix: validate C enum inputs at the FFI boundary #86 and index: create indexes with names, waits and tuning options #103), includingLanceDBVectorIndexConfig.distance_type;LanceDBIndexInfoandLanceDBIndexStatisticsversus private Rust ownership of the freed strings;conston Arrow inputs tolancedb_json_matches.Temporary fixtures cover signature, enum-name, wrong-enum, and pure
_Alignaslayout drift. A focusedunsigned long long→unsigned longfixture passes the host LP64 check and fails the LLP64 check, so a Windows-only return-value break is not hidden.Validation:
3ebc2f2: strict C17, Clippy, both-targetcheck-abiand Test all passed (job 137054963631).c0c7331(mainebf705f, including index: wait for named indices with a bounded timeout #85/ipc: add Arrow IPC file transport for inputs and query results #87/index: create indexes with names, waits and tuning options #103/index: remove unreachable index type fallback #117): host and Windows MSVC LLP64 both match 146 extern functions, 25 public structs and 5 shared enums; all fixtures are detected. The named-wait declarationlancedb_table_wait_for_indexis included.LanceDBIpcBuffertype are in that set: the six IPC entry points and the two-field buffer struct are present in both the header and cbindgen output, and their LP64/LLP64 layouts agree.lancedb_table_count_rows/lancedb_table_versionreturn mismatches on LLP64._Alignasfixtures fail with the expected enumerator, field and offset diagnostics.tests/c17_consumer.ccompiles with-std=c17 -Wall -Wextra -Werror -pedantic;tests/test_c_enum_inputs.ccompiles.Limits: this is a declaration check for the host and Windows data models, not a native MSVC link/run test. Native C17 consumer jobs are platform runtime smoke tests rather than full declaration coverage; MSVC C17 CI remains owned by #107. This slice does not add export restrictions, version introspection, release packaging or runtime changes.
Refs #99. #99 stays open for the remaining slices.