Skip to content
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

cbindgen stumbles over egl type aliases #2575

Closed
jimblandy opened this issue Apr 3, 2022 · 0 comments · Fixed by #2576
Closed

cbindgen stumbles over egl type aliases #2575

jimblandy opened this issue Apr 3, 2022 · 0 comments · Fixed by #2576

Comments

@jimblandy
Copy link
Member

jimblandy commented Apr 3, 2022

The following code in wgpu-hal/src/gles/egl.rs triggers a bug in cbindgen:

#[cfg(not(feature = "emscripten"))]
type EglInstance = egl::DynamicInstance<egl::EGL1_4>;

#[cfg(feature = "emscripten")]
type EglInstance = egl::Instance<egl::Static>;

As described in mozilla/cbindgen#286, cbindgen stumbles when the same name refers to a generic type in one module and a non-generic type in another, and then a type alias is introduced for one in the scope of the other. (As the docs warn, cbindgen doesn't really understand Rust modules).

To reproduce, run cbindgen --lang C in the wgpu-hal directory (using cbindgen version 0.19.0). For me, this panics:

thread 'main' panicked at 'Instance is not generic', src/bindgen/ir/opaque.rs:105:9

This is obviously a cbindgen bug, not wgpu's problem. But comments in the cbindgen issue linked above ominously suggest that this is a consequence of mozilla/cbindgen#7, which seems like a pretty difficult architectural issue to fix. So I think it makes sense for wgpu to work around it.

jimblandy added a commit to jimblandy/wgpu that referenced this issue Apr 3, 2022
The definition of `EglInstance` trips mozilla/cbindgen#286. Since
the `wgpu_hal::gles::egl` module is an implementation detail anyway,
it should be harmless to ask cbindgen to just ignore it.

Fixes gfx-rs#2575.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant