Skip to content
  • gnzlbg's avatar
    Fix build on all platforms · a17a91cd
    gnzlbg authored
    This PR fixes the build on all platforms and all Rust version down to the
    minimum Rust version supported by libc: Rust 1.13.0.
    
    The `build.rs` is extended with logic to detect the newer Rust features used by
    `libc` since Rust 1.13.0:
    
    * Rust 1.19.0: `untagged_unions`. APIs using untagged unions are gated on
      `cfg(libc_unions)` and not available on older Rust versions.
    
    * Rust 1.25.0: `repr(align)`. Because `repr(align)` cannot be parsed by older
      Rust versions, all uses of `repr(align)` are split into `align.rs` and
      `no_align.rs` modules, which are gated on the `cfg(libc_align)` at the top
      level. These modules sometimes contain macros that are expanded at the top
      level to avoid privacy issues (`pub(crate)` is not available in older Rust
      versions). Closes #1242 .
    
    * Rust : `const` `mem::size_of`. These uses are worked around with hardcoded
      constants on older Rust versions.
    
    Also, `repr(packed)` structs cannot automatically `derive()` some traits like
    `Debug`. These ha...
    a17a91cd