Re: [PATCH v2 0/5] rust: generate bindings via cbindgen
- From
Ezekiel Newren <ezekielnewren@gmail.com>
- Date
- Oct 28, 2025, 19:37 UTC
- Message-ID
- <CAH=ZcbAC_u88_cD33bRxAuAPhJh02zNOHAVnkhxthncDFdZOOA@mail.gmail.com>
- In-Reply-To
- <20251024-b4-pks-rust-cbindgen-v2-0-4b4bd4f18490@pks.im>
On Fri, Oct 24, 2025 at 3:51 AM Patrick Steinhardt <ps@pks.im> wrote:
Show 23 quoted lines
> > Hi, > > this small patch series introduces support for cbindgen(1). This tool is > used to generate C headers from `extern "C"` blocks so that Rust code > can easily be called from C code. > > For now, the only use case is to verify that our varint reimplementation > matches the C implementation. But later on this can and will be used to > call Rust-specific features from C, as well. > > The topic is built on top of c54a18ef67 (The twenty-second batch, > 2025-10-22) with ps/ci-rust at e509b5b8be (rust: support for Windows, > 2025-10-15) merged into it. > > Changes in v2: > - Take some of the pieces from Ezekiel's "cbindgen.toml" file. I have > not yet taken `usize_is_size_t`, as that option requires cbindgen > v0.16.0, which is not available on Ubuntu 20.04. > - Backfill missing jobs for GitLab CI. > - Fix CI failures on Alma Linux 8 because cbindgen isn't available > there. > - Link to v1: https://lore.kernel.org/r/20251023-b4-pks-rust-cbindgen-v1-0-c19b61b03127@pks.im
I really think that this patch series should include migrating to a
Cargo Workspace. That'll mean moving /Cargo.toml and /src into
gitcore/ and creating a new top-level /Cargo.toml with the following
content:
[workspace]
members = [
"gitcore",
]
resolver = "2"Along with the other cascading refactor changes needed to make this work. Let's do this now while it's still easy.
If we don't do this now then we'll be locked into a single crate project forever because there'll be too much momentum later. Having the ability to define multiple crates allows us to: * Easier to understand the big picture of Git as each logical component will be its own crate * Make Git more modular * Design better api interfaces between logically separate code * define a header file per crate via cbindgen * avoid gordian knot problems from making Rust a monolithic component * easier to reduce dependency sprawl as each crate only defines what it needs * Improves compile times through incremental rebuilds. Cargo caches build artifacts per crate. When only one crate changes, others don’t need to recompile. This becomes a major quality-of-life improvement as the Rust footprint grows.