-
Notifications
You must be signed in to change notification settings - Fork 419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
liburing-ffi headers #921
Comments
@axboe there's two libraries "liburing.a" and "liburing-ffi.a",but |
is ffi varient just -fno-inline-functions |
Languages and applications that can't use 'static inline' functions in If you can use the header, then there is no point in using FFI. The FFI version is supposed to be used by programming languages that |
how do i get metadata without header |
I don't even know the signature of the function because there is no header |
The signature doesn't change; still the same as the non-FFI version. What programming language are you working on? |
Use the same signature as the non-FFI version. |
im using rustbindgen to generate rust definition of c headers Does it mean that if liburing-ffi.h exists, just delete all static inline and function body? |
Yes, exactly. |
rustbindgen is an automated tool to generate rust bindings from c language headers, I don't like manual bindings because manual is fragile and complicated |
I mean liburing-ffi.h is needed because the existing C header files are not suitable for rustbindgen or similar automation tools, and this may make things less complicated |
I don't know about rustbindgen, but from a quick google, I found this: Does that solve your problem? |
I tried, it didn't help, it just made things more complicated |
Link time optimization should be able to ignore static inline |
The header file is static inline, but the binary is an normal function, I am curious how this is done |
All In the FFI version, we get rid of those
It's defined in: The ffi.c is what liburing-ffi.a and liburing-ffi.so are made of. |
Looking at your case where other languages can generate the binding |
If IOURINGINLINE is empty, isn't the function body redundant? |
I found that I know little about C language |
No, the body is not redundant. If If
Obviously, that's how the current FFI binaries are made.
You need to remove the body as well. The original |
Perhaps the c header is not suitable for ffi. Perhaps XML should be used to describe metadata. That's what vulkan does, and so does the Windows api |
Can you expand on that? Why it made things more complicated? I can easily generate the binding this way:
and get all io_uring static inline function signatures: |
I don't like experimental, and it's the equivalent of translating c to rust, which isn't ffi at allchanged |
I actually just mantain the bindings by hand in Rust, I don't like bindgen exactly for the reasons discovered in this issue. liburing's API even includes macros. bindgen is good for simple tools but in general, it's more robust to own your own declarations from Rust. |
I seem to have solved it, renamed ffi.c to ffi.h, |
Tested and it works
|
miniuring on crates.io |
This is actually not a liburing problem. Any language that opt in to use liburing FFI should provide their way to connect with liburing-ffi, not the other way around.
Only the signatures. Not the body.
That's FFI, the functions are still defined in
BTW, the rename is not necessary, the following also works:
It generates exactly the same binding as the experimental feature except that it doesn't have something like
|
you are right |
im linking to liburing-ffi.a
you says that
im using rustbindgen to generate rust definition of c headers
but rustbindgen cannot handle inline functions
i need liburing-ffi.h instead of liburing.h
changed
rustbindgen can handle static inline
The text was updated successfully, but these errors were encountered: