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

The use-bindgen feature does not work on windows #1288

Open
neonmoe opened this issue Feb 21, 2023 · 3 comments
Open

The use-bindgen feature does not work on windows #1288

neonmoe opened this issue Feb 21, 2023 · 3 comments

Comments

@neonmoe
Copy link

neonmoe commented Feb 21, 2023

Or at least it seems like it. I found at least two comments on this issue tracker coming across the same (or at least very similar) error (1, 2). I got this while investigating why SDL_CreateThread was segfaulting, finally realizing it was due to the default bindings (turns out, the function has two more arguments on windows), and then attempting to enable the use-bindgen feature.

error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type
     --> C:\Users\jens\Desktop\sdl2-no-std-base\target\debug\build\sdl2-sys-72b695ace8247066\out/sdl_bindings.rs:71129:1
      |
71129 | pub struct _IMAGE_TLS_DIRECTORY64 {
      | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |
note: `_IMAGE_TLS_DIRECTORY64__bindgen_ty_1__bindgen_ty_1` has a `#[repr(align)]` attribute
     --> C:\Users\jens\Desktop\sdl2-no-std-base\target\debug\build\sdl2-sys-72b695ace8247066\out/sdl_bindings.rs:71147:1
      |
71147 | pub struct _IMAGE_TLS_DIRECTORY64__bindgen_ty_1__bindgen_ty_1 {
      | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `_IMAGE_TLS_DIRECTORY64` contains a field of type `_IMAGE_TLS_DIRECTORY64__bindgen_ty_1`
     --> C:\Users\jens\Desktop\sdl2-no-std-base\target\debug\build\sdl2-sys-72b695ace8247066\out/sdl_bindings.rs:71135:9
      |
71135 |     pub __bindgen_anon_1: _IMAGE_TLS_DIRECTORY64__bindgen_ty_1,
      |         ^^^^^^^^^^^^^^^^
note: ...which contains a field of type `_IMAGE_TLS_DIRECTORY64__bindgen_ty_1__bindgen_ty_1`
     --> C:\Users\jens\Desktop\sdl2-no-std-base\target\debug\build\sdl2-sys-72b695ace8247066\out/sdl_bindings.rs:71141:9
      |
71141 |     pub __bindgen_anon_1: _IMAGE_TLS_DIRECTORY64__bindgen_ty_1__bindgen_ty_1,
      |         ^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0588`.

I'm clueless about bindgen, so I don't know if anything can be done on this crate's side, but a cursory search revealed that this might be caused by this issue in bindgen? Can anyone else reproduce this? Could sdl2-sys work around this somehow?

@datalus
Copy link

datalus commented May 2, 2023

Yes, I can reproduce this on Windows. It does appear to be a longstanding issue with bindgen that you linked.

Has anyone found a possible workaround for this?

@juliusl
Copy link

juliusl commented Jun 5, 2023

So ran into this thread while trying to fix this issue,

I think in this particular case you should be able to ignore these types. This would need to be added to the bindgen code:

        .blocklist_type("IMAGE_TLS_DIRECTORY")
        .blocklist_type("PIMAGE_TLS_DIRECTORY")
        .blocklist_type("IMAGE_TLS_DIRECTORY64")
        .blocklist_type("PIMAGE_TLS_DIRECTORY64")
        .blocklist_type("_IMAGE_TLS_DIRECTORY64")

For more information on what this type does, you can read about it here -- https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#the-tls-section -- It's a very specific static Thread Local Storage implementation so I doubt it's being used but a maintainer would need to chime in.

@juliusl
Copy link

juliusl commented Jun 6, 2023

Same solution was posted here --- rust-lang/rust-bindgen#1562 (comment)

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

No branches or pull requests

3 participants