-
Notifications
You must be signed in to change notification settings - Fork 10
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
Remove bindgen dependency #37
Conversation
It's worth pointing out that the bindings are slightly different on ARM because there is no Checkout this PR to try and fix it: tov/libffi-rs#14 But other than that it seems like a great idea. I've been dealing with version issues lately caused by conflicted versions of libclang. |
@timfish I don't have any ARM hardware to test this on, but by the looks of it we can just copy the |
@timfish I have adopted the |
Yep, I've got a Windows machine and a Raspberry Pi that I'll give this a try on. |
Testing results thus far:
Testing was done by running EDIT 1: This is also happening when you run EDIT 2: It seems that on MSYS2 the DLL is called |
|
This removes the dependency on bindgen, replacing it with a set of bindings directly included in the repository. The bindings were generated on Linux, cleaned up, then compared with the bindgen output for MacOS and Windows (using MSYS2). Apart from some noise caused by unused constants, the libffi API code was the same. Removing bindgen cuts down the amount of dependencies, most notably the dependency on libclang. Removing this simplifies the installation procedure, as well as simplifying the build scripts a bit. The complex FFI types are hidden behind a "complex" feature flag that is disabled by default, similar to the libffi-rs crate. The longdouble type is disabled on GNU/Linux ARM devices, per #37 (comment) and tov/libffi-rs#14. This fixes #31.
Correct, it static links the source install of libffi. I have no idea how dynamic linking and library management works under MSVC, or how you'd even install libffi. |
I think on Windows you can use Vcpkg but I wouldn't worry about it. I can't see anybody using it when there's reliable static linking. |
I've been unable to get dynamic linking on MSYS2 to work, even when using the Rust provided by Since this is not a new issue, I think we can leave this as-is. As far as I understand, static linking on Windows is preferred anyway. |
@tov could you take a look at these changes? Thanks! p.s. If you need help maintaining the crates and such, please let me know; I'm more than happy to help increase the bus factor 😃 |
For those that want to try this pull request by patching their [patch.crates-io]
libffi-sys = { git = "https://github.com/YorickPeterse/libffi-sys-rs.git", branch = "no-bindgen-patch" }
libffi = { git = "https://github.com/YorickPeterse/libffi-rs.git", branch = "no-bindgen-patch" } These branches contain these changes in this PR, in addition to a version change so they can be used to patch existing installations. To apply them, you need to run |
Worth mentioning: with these changes I can reduce my clean |
This patches the libffi and libffi-sys crates to use the changes discussed in tov/libffi-sys-rs#37. This removes the dependencies on bindgen and libclang, making the installation process easier and faster.
@tov Do you have time to look at this PR any time soon? Thanks! |
Hey! Sorry. I am going to make you a maintainer, @yorickpeterse. I very much appreciate the offer. |
Inlining all the magic numbers from |
@tov Thanks for adding me! Unfortunately there's no other way to provide these constants, as they are all created using |
Since there don't seem to be any particular objections against these changes, I believe we can go ahead and merge them. |
This removes the dependency on bindgen, replacing it with a set of bindings directly included in the repository. The bindings were generated on Linux, cleaned up, then compared with the bindgen output for MacOS and Windows (using MSYS2). Apart from some noise caused by unused constants, the libffi API code was the same.
Removing bindgen cuts down the amount of dependencies, most notably the dependency on libclang. Removing this simplifies the installation procedure, as well as simplifying the build scripts a bit.
The complex FFI types are hidden behind a "complex" feature flag that is disabled by default, similar to the libffi-rs crate. The longdouble type is disabled on GNU/Linux ARM devices, per #37 (comment) and tov/libffi-rs#14.
This fixes #31.
Testing results
cargo test
cargo test --features system
master