Closed
Conversation
Co-authored-by: Eli Arbel <46826214+eliarbel@users.noreply.github.com>
Collaborator
|
One or more of the following people are relevant to this code:
|
Member
|
Shall we close this PR? For the time being at least, we don't seem to be heading in this direction, and the PR's just going to get super stale if left open. |
Member
|
Since Julien didn't reply, I'll just close it (since I assume that's the correct state) and see if he re-opens it to indicate I was wrong. |
Collaborator
Author
|
Whoops sorry, this fell off my radar. I would expect that sooner or later we'll want to do this for the reasons listed in the description, but I'm also fine keeping it for now since we were able to circumnavigate problems so far. |
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.
Summary
This PR implements the headers for the C API manually and removes the dependency on
cbindgen.This needs rebasing on top of #14340.
Details
The header structure here is proposed as
Why remove
cbindgen?cbindgenis a tool we currently use to automatically generate the header for the C FFI for Rust, off the.rsfiles that expose Rust structs, enums and functions. It's been super useful in starting the C API, but we're already hitting some limitations and expecting some more serious limitations in the future. The two main points IMO are:cbindgentreats all objects as part of a global namespace: this means that trying to expose an objectsome_namespace::Thingto C only works if there is no other object calledThingin the parsed Rust API. This is a fundamental limitation incbindgen, which they also mention in their docs.cbindgen. But that requires active PR and issue reviews.Smaller problems we can work around (but that get a bit annoying and sum up):
cbindgenpulls the Rust docs of objects we expose as opaque pointers. For example, we exposeSparseObservableastypedef struct SparseObservable SparseObservableto C, which causes the header to include the Rust docstring. We currently solve this by manually writing the Sphinx docs for these objects. This also affects enums we directly expose, such asBitTerm.cbindgens export control.Why keep
cbindgen?cbindgen(as we're trying with Allow excluding prefixes for objects mozilla/cbindgen#1064). The global namespace could be a dealbreaker in the longer run, though.Todos
QkComplex64to the C API #14340, once merged