rust-bindgen: `_Float16 _Complex` leads to panic (such as when including `immintrin.h` on clang 16)
Input C/C++ Header
/* input.h */
_Float16 _Complex h;
Bindgen Invocation
$ bindgen input.h
Actual Results
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))', J:\Compilers\Rust\.cargo\registry\src\github.com-1ecc6299db9ec823\bindgen-0.65.1\ir\context.rs:1994:26
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 include avx512fp16intrin.h and avx512vlfp16intrin.h, which in turn have construct _Float16 _Complex, which currently bindgen cannot handle.
For example, running bindgen on SDL2’s SDL.h which includes immintrin.h through SDL_cpuinfo.h results in the above error.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 17 (7 by maintainers)
Commits related to this issue
- Work around rust-lang/rust-bindgen#2500 Based on https://github.com/MikuroXina/rich-sdl2-rust/issues/50 — committed to Dr-Emann/croaring-rs by Dr-Emann 3 years ago
- Work around rust-lang/rust-bindgen#2500 Based on https://github.com/MikuroXina/rich-sdl2-rust/issues/50 — committed to Dr-Emann/croaring-rs by Dr-Emann 3 years ago
- Work around rust-lang/rust-bindgen#2500 Based on https://github.com/MikuroXina/rich-sdl2-rust/issues/50 — committed to Dr-Emann/croaring-rs by Dr-Emann 3 years ago
- Work around rust-lang/rust-bindgen#2500 — committed to Dr-Emann/croaring-rs by Dr-Emann 3 years ago
- Work around rust-lang/rust-bindgen#2500 — committed to Dr-Emann/croaring-rs by Dr-Emann 3 years ago
- Stop pinning clang in Windows ucrt Try the workaround mentioned in https://github.com/rust-lang/rust-bindgen/issues/2500#issuecomment-1640545912. — committed to stanhu/actions by stanhu 2 years ago
- Stop pinning clang in Windows ucrt Try the workaround mentioned in https://github.com/rust-lang/rust-bindgen/issues/2500#issuecomment-1640545912. — committed to stanhu/actions by stanhu 2 years ago
- Stop pinning clang in Windows ucrt Try the workaround mentioned in https://github.com/rust-lang/rust-bindgen/issues/2500#issuecomment-1640545912. — committed to stanhu/actions by stanhu 2 years ago
- Stop pinning clang in Windows ucrt (#55) Try the workaround mentioned in https://github.com/rust-lang/rust-bindgen/issues/2500#issuecomment-1640545912. — committed to oxidize-rb/actions by stanhu 2 years ago
If https://github.com/rust-lang/rfcs/pull/3453 gets merged, we might have a clearer way forward here.
For reference, a more precise way to work around this issue is to define the preprocessor definitions
__AVX512VLFP16INTRIN_Hand__AVX512FP16INTRIN_, instead of undefining__SSE2__entirely:This effectively disables the C definitions (
_Float16 _Complex ...) that tripbindgeninsideavx512vlfp16intrin.handavx512fp16intrin.h.And, of course,
bindgenversion0.66.1stumbles at a different place even with this work around, so one would need to fetch and build themainbranch for the moment.Notice that, using
bindgenbuilt frommainbranch (commit2df02c2668f41d35616c8385ed61ada896a4bf4c) fixes the second issue above, so that the following succeeds: