-
Notifications
You must be signed in to change notification settings - Fork 729
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
Macro defining a constant with unsigned long suffix generates unsigned integer #923
Comments
Thanks for the report! For macro definitions we use We have a way to customise it from bindgen though, which is using the Maybe that suits you, otherwise, would you consider filing an issue against https://github.com/jethrogb/rust-cexpr? Thanks! |
Looks like this never happened, but someone later filed a bug about this here: |
Though given this crate is also used to evaluate expressions, there's probably a deeper flaw here that bindgen does not correctly incorporate types when evaluating these. (This then opens a whole different can of worms around how |
There's a more important issue here and it is the fact that |
Since ed57762, pub const CK_INVALID_HANDLE: u32 = 0; |
All that did was switch the hardcoded types from |
yes |
Due to rust-lang/rust-bindgen#923, bindgen does not evaluate constants correctly. This means arithemetic is done with the wrong type, and more importantly the output has the wrong type. Ultimately, this is a bug in bindgen, but as that's remains unfixed, we'll have to work around it. rust-openssl's bindgen mode works around this by using the build.rs bindgen driver and registering a callback to fix the type. This won't work for some of our consumers, which require a hermetic and reproducible builds. Instead, apply bssl-sys's workaround at the lib.rs level. This removes a divergence between bssl-sys and rust-openssl's bindgen mode. Fixing these types does not mean we recommending using all of these constants! Many of the options here are ill-defined or produce even more ambiguous output than most. XN_FLAG_COMPAT is especially fun because it change the calling convention! The only option anyone should use is XN_FLAG_RFC2253, as that's at least a well-defined output. Fixed: 636 Change-Id: Id34b4a46e0cfd6dcb275477d9bb915bda66c787d Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/66228 Reviewed-by: Bob Beck <bbe@google.com> Commit-Queue: David Benjamin <davidben@google.com>
A workaround for this issue was to manually regex replace these values inside your build.rs:
|
This assumes that there are no other uses of Ultimately the problem here is that bindgen is not correctly consuming C headers. All the information is in there, in a perfectly machine-readable manner. bindgen just throws the information away. |
Just bumped into this one with bindgen@v0.70.1: #define LOW_PC_MASK 0x000000000000FFFFLLU error[E0308]: mismatched types
--> src/bpf/profiler_bindings.rs:78:25
|
78 | let mask: u64 = LOW_PC_MASK;
| --- ^^^^^^^^^^^ expected `u64`, found `u32`
| |
| expected due to this
|
help: you can convert a `u32` to a `u64`
|
78 | let mask: u64 = LOW_PC_MASK.into();
| |
Input C/C++ Header
Bindgen Invocation
Actual Results
Expected Results
The U (unsigned) prefix is taken into account, but not the L (long) one.
This causes types and casts problems.
Debugging logs:
bindgen.txt
The text was updated successfully, but these errors were encountered: