Generate the meos-sys FFI from the MEOS-API catalog - #6
Conversation
meos-sys parsed the MEOS headers with bindgen at build time and carried committed prebuilt-bindings snapshots. Replace both with a projection of the MEOS-API catalog, the single source of truth every MobilityDB binding derives from: sys/codegen.py emits sys/src/generated.rs from meos-idl.json, and sys/build.rs only locates and links libmeos. The FFI is derived from the stable-1.3 line the crate pins. A drift-check CI job provisions the catalog and asserts the committed generated.rs matches it, so a MEOS API change surfaces instead of silently rotting the FFI. tools/refresh-from-master.sh regenerates it in one command, the same entry point as every other MobilityDB binding. The public meos crate (src/) is unchanged; wrapper.h and prebuilt-bindings/ are removed.
|
I've asked an LLM to draft in a message my thoughts. Overall I understand the idea but for the Rust case I fail to see the advantage over the current approach. Review: Generate the meos-sys FFI from the MEOS-API catalog (#6)I don't think this PR should be merged in its current form. The concerns below are ordered by importance, and all of them are verifiable from the diff itself. 1. It replaces a well-tested framework (bindgen) with a custom, untested Python script — this is the core problemThe PR swaps rust-bindgen — a mature tool maintained by the Rust project, used by thousands of crates, and battle-tested against every C corner case (varargs, unions, bitfields, flexible array members, per-platform integer widths) — for a bespoke 319-line The "single source of truth" argument is also circular: 2. It introduces concrete UB / ABI bugs
3. It deletes the safety net that makes a raw FFI trustworthy
4. It breaks the version features while claiming nothing changes
5. CI and supply-chain regressions
6. Why this approach brings little benefit to Rust specifically — and why bindgen's advantages are biggerThe catalog approach was designed to solve a problem Rust doesn't have:
Weighing the two sides: bindgen gives ABI fidelity (varargs, unions, function pointer types), per-target correctness, compile-time layout verification, an escape hatch against the user's actual installed headers, ecosystem familiarity, and upstream maintenance by the Rust project — automatically, with no code owned by this repo. The catalog gives workflow uniformity with the other MobilityDB bindings and drift detection, the latter of which bindgen can also provide. The trade is heavily lopsided against this PR. |
How meos-rs could leverage MEOS-API without replacing bindgenTo be clear, I think the MEOS-API catalog is valuable — the objection is only to using it as the generator of the Rust ABI. The split that works is: the catalog is the authority on what the MEOS API surface is; bindgen stays the authority on how it maps to ABI-correct Rust. Concretely, here is how we could use MEOS-API and capture every benefit this PR claims: 1. Catalog as bindgen's allowlistThe most legitimate gripe with the current prebuilt bindings is the glibc noise ( 2. Catalog as a drift oracle in CIKeep the drift-check job, but instead of regenerating the FFI from the catalog, cross-check the committed bindgen output against it: functions present in the bindings must match the catalog's signatures (name, arity), and stale extras are flagged. Since the bindings don't yet cover the full catalog (e.g. the cbuffer/npoint/pose families), the check can start one-directional — "nothing in the bindings drifts from the catalog" as a hard failure, "catalog functions missing from the bindings" as a report — and tighten to bidirectional once coverage catches up. A MEOS API change still surfaces as a CI failure — the exact property this PR advertises — with zero ABI risk. 3.
|
|
Dear David ! Many thanks for this great analysis ! It would be great that you implement the approach you suggested. Looking forward to it ! |
meos-sys is a projection of the MEOS-API catalog (the single source of truth every MobilityDB binding derives from) instead of bindgen:
sys/codegen.pyemitssys/src/generated.rsfrommeos-idl.json, andsys/build.rsonly locates and links libmeos.wrapper.handprebuilt-bindings/are removed.The FFI derives from the stable-1.3 line the crate pins (the 1.3 family set has no
-DALL). A drift-check CI job provisions the catalog and asserts the committedgenerated.rsmatches it, so a MEOS API change surfaces instead of silently rotting the FFI.tools/refresh-from-master.shregenerates it in one command — the same entry point as GoMEOS, MEOS.NET, and the JVM bindings.The public
meoscrate (src/) is unchanged — this touches only thesys/FFI layer, invisible to users.