Skip to content

error[E0588]: packed type cannot transitively contain a #[repr(align)] type #102733

Closed
@olivier-fs

Description

@olivier-fs

Hi!

I'm trying to build the bindgen tutorial example from :
https://rust-lang.github.io/rust-bindgen/tutorial-0.html
=> https://github.com/fitzgen/bindgen-tutorial-bzip2-sys
=> https://fitzgeraldnick.com/2016/12/14/using-libbindgen-in-build-rs.html

It's an exemple binding to bzip2 (just as an exemple ; the author knows about bzip2 and bzip2-sys crates).

I'm using :

  • rustc 1.64.0 (a55dd71 2022-09-19)
  • bindgen-0.60.1
  • LLVM-15.0.1 (clang version 15.0.1, Target: x86_64-pc-windows-msvc, InstalledDir: C:\dev\llvm-15.0.1\bin)
  • Windows 10
  • MSYS2/Mingw64 : clang64/mingw-w64-clang-x86_64-bzip2 1.0.8-2 as the provider of C package bzip2

After adding some bindgen::Builder config in build.rs to set path to included <bzlib.h> :

.clang_arg("-IC:/dev/msys64/clang64/include")

I'm getting this error :

$ cargo build
   Compiling bindgen-tutorial-bzip2-sys v0.1.0 (C:\Users\olivier\dev\rust\www-sample\interop\c\bindgen-tutorial-bzip2-sys)
error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type
     --> C:\Users\olivier\dev\rust\www-sample\interop\c\bindgen-tutorial-bzip2-sys\target\debug\build\bindgen-tutorial-bzip2-sys-03a76bb986e88418\out/bind

ings.rs:64916:1
      |
64916 | pub struct _IMAGE_TLS_DIRECTORY64 {
      | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |
note: `_IMAGE_TLS_DIRECTORY64__bindgen_ty_1__bindgen_ty_1` has a `#[repr(align)]` attribute
     --> C:\Users\olivier\dev\rust\www-sample\interop\c\bindgen-tutorial-bzip2-sys\target\debug\build\bindgen-tutorial-bzip2-sys-03a76bb986e88418\out/bind

ings.rs:64933:1
      |
64933 | 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\olivier\dev\rust\www-sample\interop\c\bindgen-tutorial-bzip2-sys\target\debug\build\bindgen-tutorial-bzip2-sys-03a76bb986e88418\out/bind

ings.rs:64922:9
      |
64922 |     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\olivier\dev\rust\www-sample\interop\c\bindgen-tutorial-bzip2-sys\target\debug\build\bindgen-tutorial-bzip2-sys-03a76bb986e88418\out/bind

ings.rs:64928:9
      |
64928 |     pub __bindgen_anon_1: _IMAGE_TLS_DIRECTORY64__bindgen_ty_1__bindgen_ty_1,
      |         ^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0588`.
error: could not compile `bindgen-tutorial-bzip2-sys` due to previous error

I tried with nightly toolchain (currently 1.66.0)

  • with cargo +nightly build
  • by adding some bindgen::Builder config in build.rs : .rust_target(bindgen::RustTarget::Nightly)
    but I get the same error.

I see that issue #67383 with the same problem has been closed.

  • Is rustc complain valid (i.e. bindgen has generated some "invalid" code), or is rustc hitting an error despite of valid bingen output ?
  • Is this error anyway related to rust/rustc, or should I forward the issue to bindgen ?
  • Otherwise, what to do to solve this, as I tried with latest stable rust and bindgen versions ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions