-
Notifications
You must be signed in to change notification settings - Fork 694
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
Produce portable output (avoid generating system-dependent tests + configuration to improve type replacements) #424
Comments
So the autogenerated tests are useful for plenty of reasons (most notably sanity-check when you're using C++), but it's a fair concern and should be pretty easy to add an option to avoid generating them. Re. deriving Do you have any thoughts @fitzgen? |
An option to avoid layout tests is fine by me. Options surrounding control of deriving The larger concept of intimately understanding portability and types in bindgen and the bindings we emit is a -1 for me. That sounds like too much complexity, and I think C++ and templates has already eaten our whole complexity budget. |
Ha, yes, the title of this issue is maybe a bit grander than it ought to be! What I'm actually interested in of course is just the three specific suggestions that I made. I'm very happy for you to consider them on their own merits - without anyone having to be sucked into some more general and complicated project. |
Ok, then yeah those things all seem fine to me. |
An option for disabling deriving debug landed today, disabling test generation should be straight forward. |
Please make a comment here if you intend to work on this issue. Thank you! |
A good first bug even! |
@andrew-x You might be interested in fixing this (it's a tool that is used to support Servo, rather than directly in Servo proper). |
Hi @jdm I'd like to take a shot at this. I'll try to set up a development environment first then I'll likely come back with a bunch of questions. |
@andrew-x that's awesome! Let us know when you need anything :) |
@andrew-x Have you made any progress here? Any questions so far? |
Hey sorry for radio silence. I was able to setup a dev environment (on windows 10) and I am able to successfully build with "cargo build", but when I try "cargo test" I get a bunch of fails. I am also confused on the module and the issue so had a couple of clarification questions.
Sorry for these rather basic sounding questions, any help is appreciated! |
@andrew-x Are you using the nightly version of rustc? |
@andrew-x bindgen takes C/C++ header files as input, and spits out Rust FFI bindings that can be used to interact with the original C/C++ libraries. |
Unassigning due to lack of activity. |
Option to avoid generating layout tests as discussed in #424
Is this issue resolved? If not, I could work on it |
There is still no way to disable test generation, so that would be great! |
Can you tell me briefly what's needed to be done since #632 got merged? |
Oh, my mistake. @fitzgen Is there anything left to do here? |
Bullet 1 of my original report is still entirely open, and bullet 2 partially so. For a little more context: here are the patches I currently apply to the bindgen-generated code:
As you can see, this is a pretty small set of modifications to make to the autogen code so no big deal for me if you decided that it's more trouble than it's worth to worry about them. Edit: oh, and I missed the adding of |
So, a few points:
The idea is to call bindgen with
We have an (opt-in) way to generate/derive
We should add more control over how we treat blacklisted items, but that's not easy right now. We can definitely add an option to assume nothing about them, but even though it'd fit your use-case, I'm not sure it'd be generic enough.
That'd break workflows that |
Thanks! Summary of the below is: yes, you're quite right, let's not do anything more under the banner of #424. In turn:
|
I'm going to close this issue because it seems like we've reached consensus that there isn't anything left to do here. If there is still stuff to do, I'd appreciate it if we opened new, more narrowly focused and well-defined follow up issues, because the scope here is a bit unclear to me. Thanks! |
I prefer to generate my FFI code once and then distribute that, rather than generate it at build time. I see that you recommend the opposite, but even so: I expect that plenty of my potential users - especially on Windows - won't have the required dependencies installed. Better for me to figure out once how to get
bindgen
working, and be done with it.At the moment, though, I have to do a little massaging of the code produced by
bindgen
to make it portable. My life would be that little bit easier ifbindgen
could be persuaded to produce portable output in the first place.Ways in which I currently hand-modify output, and suggestions as to how this might be avoided:
The exact definition of various types defined in system headers varies. So I blacklist them, and then modify the autogenerated code to import a portable version of those types eg
use libc::timeval
bindgen
where to get a type fromOne consequence of this is that
Debug
can be wrongly derived. Eg it is derived on a structure containing anin_addr
, which I obtain aslibc::in_addr
, which doesn't implementDebug
.libc::in_addr
probably should beDebug
- derive Debug on structures? libc#302).Debug
for structures that contain itDebug
autogenerated testcases all assume that pointer size is per the machine on which they were generated. So I delete them.
bindgen
to not generate such testcasesNone of this is a big deal for me -
bindgen
is great and the work I just described really isn't very much. Feel free to close this out if it's not of interest to you!The text was updated successfully, but these errors were encountered: