-
Notifications
You must be signed in to change notification settings - Fork 716
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
_Float16 _Complex
leads to panic (such as when including immintrin.h
on clang 16)
#2500
Comments
Handling this case is relatively straightforward. The only question is to what should we map From what I read #[repr(transparent)]
struct f16(pub u16); |
Also currently facing this issue in a project that includes fmtlib/fmt. |
|
Even if it were I think it could be misleading as you'd have no warning about treating a value as an |
I think there's an issue about this behavior being incorrect as |
That's quite interesting. If you use struct A {
_Float16 foo;
}; becomes: #[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct A {
pub foo: u16,
} However just using it as a variable type alone does not work. Maybe that's known behaviour but |
Hmm that's interesting. I think this This more or less explains why |
Makes sense. |
I'd be more inclined to have a transparent wrapper instead of a full blown I'd say having a completely opaque Generating such opaque type would be out of |
Is there a temporary work around this issue? |
@koutheir A temporary workaround is to use clang <= 15. |
I cannot do that, because I have to use the same version of |
$ bindgen --version
bindgen 0.66.1 This issue can be reproduced by running: $ bindgen --verbose /usr/x86_64-w64-mingw32/include/winsock2.h -- --target=x86_64-pc-windows-gnu
Bindgen unexpectedly panicked
This may be caused by one of the known-unsupported things (https://rust-lang.github.io/rust-bindgen/cpp.html), please modify the bindgen flags to work around it as described in https://rust-lang.github.io/rust-bindgen/cpp.html
Otherwise, please file an issue at https://github.com/rust-lang/rust-bindgen/issues/new
panicked at 'Non floating-type complex? Type(_Complex _Float16, kind: Complex, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Type(_Float16, kind: Float16, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))', $HOME/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.66.1/ir/context.rs:2020:26 However, forcing the preprocessor definition $ bindgen --verbose /usr/x86_64-w64-mingw32/include/winsock2.h -- --target=x86_64-pc-windows-gnu -U__SSE2__
Bindgen unexpectedly panicked
This may be caused by one of the known-unsupported things (https://rust-lang.github.io/rust-bindgen/cpp.html), please modify the bindgen flags to work around it as described in https://rust-lang.github.io/rust-bindgen/cpp.html
Otherwise, please file an issue at https://github.com/rust-lang/rust-bindgen/issues/new
panicked at 'called `Result::unwrap()` on an `Err` value: FromBytesWithNulError { kind: InteriorNul(1) }', $HOME/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bindgen-0.66.1/codegen/mod.rs:717:71 |
Notice that, using $ <...>/rust-bindgen/target/release/bindgen --verbose /usr/x86_64-w64-mingw32/include/winsock2.h -- --target=x86_64-pc-windows-gnu -U__SSE2__ |
For reference, a more precise way to work around this issue is to define the preprocessor definitions $ <...>/rust-bindgen/target/release/bindgen --verbose /usr/x86_64-w64-mingw32/include/winsock2.h -- \
--target=x86_64-pc-windows-gnu -D__AVX512VLFP16INTRIN_H -D__AVX512FP16INTRIN_H This effectively disables the C definitions ( And, of course, |
If rust-lang/rfcs#3453 gets merged, we might have a clearer way forward here. |
rust-lang/rfcs#3453 is merged, there is already WIP implementation, but even when this is released it would be hidden behind RustTarget, so fallback (non- |
Input C/C++ Header
Bindgen Invocation
Actual Results
Expected Results
Command completes without error.
Synopsis
Ran into this when using a header from a project that includes
immintrin.h
, which on clang 16 always seems to includeavx512fp16intrin.h
andavx512vlfp16intrin.h
, which in turn have construct_Float16 _Complex
, which currently bindgen cannot handle.For example, running bindgen on SDL2's
SDL.h
which includesimmintrin.h
throughSDL_cpuinfo.h
results in the above error.The text was updated successfully, but these errors were encountered: