Frommi / miniz_oxide

Rust replacement for miniz
MIT License
168 stars 48 forks source link

0.2.4 broke the C API on 32-bit unix #72

Closed cuviper closed 4 years ago

cuviper commented 4 years ago

On Fedora, we found that 0.2.4 broke for i686 and armv7hl, such as this build.

error[E0308]: mismatched types
   --> src/lib.rs:252:79
    |
252 |                 as_c_return_code(mz_compress2_oxide(&mut stream_oxide, level, dest_len))
    |                                                                               ^^^^^^^^ expected `u64`, found `u32`
    |
    = note: expected mutable reference `&mut u64`
               found mutable reference `&mut u32`
error[E0308]: mismatched types
   --> src/lib.rs:291:74
    |
291 |                 as_c_return_code(mz_uncompress2_oxide(&mut stream_oxide, dest_len))
    |                                                                          ^^^^^^^^ expected `u64`, found `u32`
    |
    = note: expected mutable reference `&mut u64`
               found mutable reference `&mut u32`
error[E0308]: mismatched types
   --> src/c_export.rs:150:23
    |
150 |             total_in: self.total_in,
    |                       ^^^^^^^^^^^^^ expected `u32`, found `u64`
error[E0308]: mismatched types
   --> src/c_export.rs:160:24
    |
160 |             total_out: self.total_out,
    |                        ^^^^^^^^^^^^^^ expected `u32`, found `u64`
error[E0308]: mismatched types
   --> src/c_export.rs:211:23
    |
211 |             total_in: stream.total_in,
    |                       ^^^^^^^^^^^^^^^ expected `u64`, found `u32`
error[E0308]: mismatched types
   --> src/c_export.rs:213:24
    |
213 |             total_out: stream.total_out,
    |                        ^^^^^^^^^^^^^^^^ expected `u64`, found `u32`
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0308`.
error: could not compile `miniz_oxide_c_api`.

I bisected the regression to commit 918aa73285e3. For the mz_uncompress2_oxide errors, that parameter changed from &mut c_ulong to &mut u64. StreamOxide's total_in and total_out also changed from c_ulong to u64. Those are the same type on LP64 targets (most 64-bit Unix), but not on 32-bit targets, nor 64-bit Windows (LLP64).

See also #54.

oyvindln commented 4 years ago

Yeah that was a slip, need to make sure the data types line up. The C API is in bad shape in general.

cuviper commented 4 years ago

Thank you, 0.2.5 built on all Fedora arches without trouble.