-
Notifications
You must be signed in to change notification settings - Fork 696
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
Auto-generated test failure using <link.h> on Debian 9. #1370
Comments
Is there any chance of knowing the preprocessed input? Otherwise it's going to be hard to figure out. If you feel like trying creduce to reduce it it'd be awesome as well! |
Oh, the predicate script is only for reducing it. The |
Gzipped |
Any joy? Thanks |
Sorry, I haven't had the chance to look at this in detail yet. |
Hi emilio, How does one go about debugging this test failure? I see the test in bindings.rs, but it's large and all on one line. Is there a way to get this in a more human-readable format? We have a PR blocked on this issue, so I'm keen to push on. Thanks |
If you have rustfmt installed you should get the bindings properly formatted. |
I've made a little progress.
Rust expects the The Rust definition (and the types it depends on) look like this:
I've annotated the sizes of things using comments, and determined that this lot is of size 224. The C definition looks like this:
I think bindgen is not dealing with the conditionally compiled fields properly. The size of these structs depends on macros:
(oddly enough, not 224 in either case, probably more macros) Does any of this help? |
Actually, that statement can't be right. Any ideas? |
Here's the real problem:
becomes:
Which I think is incorrect. On my system, a Related: #550 |
Ahá |
We use f64 because rust didn't have f128 at the time and u128 and such were unstable... |
We could generate u128 conditionally there now, I'd think... |
Hey Emilio,
Sounds good, but why conditionally?
Cheers
…On Tue, 18 Sep 2018, 19:22 Emilio Cobos Álvarez, ***@***.***> wrote:
We could generate u128 conditionally there now, I'd think...
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1370 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAk7G9DTxKWeLMS46YKJS9BnW2nsEbltks5ucTntgaJpZM4WGCB7>
.
|
Because we want to support old rust versions, so it'd need to be behind a |
I took a bit of spare time to implement the first step to properly do that: #1391. That fixes integer generation. Then I need to teach the rest of the codegen to conditionally support that, but shouldn't be terrible. |
I ended up doing the whole thing :) |
Note that there's an unexpected gotcha here: rust-lang/rust#54341. |
Hi emilio,
Wow thanks. I'll give it a go. Looks like this branch:
Whilst I don't think this will affect my test case, I think it should be fixed. Having things randomly crash because of incorrect alignment aint good. It aint Rust :) Ideally, Rust (or the |
FWIW, the test still fails on that branch. |
Have you enabled |
I think I did file an issue on this long time ago... But I can't find it now. It's worth a shot probably :) |
Um, no. I thought nightly would be enough. Let me give it a go. |
Right, so this makes a difference:
|
To work-around some cases of rust-lang/rust#54341. Other cases where u128 and u64 are mixed in fields might not behave correctly, but the field offset assertions would catch them. Fixes rust-lang#1370
I pushed a commit that should fix those. It's a bit of a work-around, but it only improves correctness so I think we should land it. |
And rustc already warns when using
|
Hi emilio, So should my tests pass now? Using the latest version of your u128 branch, I still have one test failure:
|
Oh, interesting, that is not a struct but a union with alignment attributes. Mind filing a new issue for that one? I'm not on my laptop now but I think it should be pretty easy to create a reduced test-case. |
Sure, I'll raise another issue. |
Hi emilio, Quick question. For how long will I need the Thanks |
It's not really a hack, it's there so bindgen will generate repr(align) attributes. We could deprecate support for older rust versions I guess, and make one version the default from now on, but it's not clear what version should that be. |
Maybe this is not possible, but wouldn't you just want something which works with whatever version of rust the user is currently running? |
Not really, because the version you run bindgen for may or may not be the version you compile the bindings for. And even if it is, bindgen output should be deterministic at least for a given architecture, or, let's say, as deterministic as the C code you're building. Otherwise imagine you develop a library using bindgen of a new compiler, and bindgen generates Then you have an user that builds that library with an old rustc compiler, and the code you wrote using the unions from bindgen no longer builds. That's not great. |
Input C/C++ Header
Sorry, I know you asked for no
#include
s, but I'm at a loss as to what the predicate script should do when I'm just importing types from the C library -- If you can't reproduce from the info below, then could you help me with the predicate script plz? :)Bindgen Invocation
Actual Results
When included, like this:
This is the only failing test.
Expected Results
Test passes.
This is on Debian 9 x86_64, using today's Rust nightly.
FWIW, OpenBSD's
<link.h>
does work on an OpenBSD system.Any ideas?
The text was updated successfully, but these errors were encountered: