Skip to content

Switch flate2 backend from zlib-ng to zlib-rs - #48

Merged
gbrgr merged 1 commit into
mainfrom
gb/flate2-zlib-rs
Aug 28, 2026
Merged

Switch flate2 backend from zlib-ng to zlib-rs#48
gbrgr merged 1 commit into
mainfrom
gb/flate2-zlib-rs

Conversation

@gbrgr

@gbrgr gbrgr commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • flate2's zlib-ng feature pulls in libz-ng-sys, which compiles zlib-ng's C source via CMake. On BinaryBuilder's aarch64-apple-darwin toolchain (Clang 22), this fails: zlib-ng's CMake ARMv8 CRC32 feature-detection incorrectly concludes the compiler lacks native __crc32b/__crc32h/__crc32w intrinsics, so it includes its own polyfill header (acle_intrins.h) — which then collides with Clang's own arm_acle.h (which already defines them), producing redefinition of '__crc32b' compile errors. Found while bumping iceberg_rust_ffi_jll in Yggdrasil (see JuliaPackaging/Yggdrasil#14575).
  • zlib-rs (a pure-Rust zlib reimplementation, no C compiler needed) is already used elsewhere in the same dependency graph — parquet (via iceberg-rust, a downstream consumer of this crate through iceberg_rust_ffi) enables flate2's zlib-rs feature. Before this change, both backends were being compiled into the same binary simultaneously, which flate2's own documentation flags as producing undefined ordering behavior when more than one backend is enabled at once. Switching to zlib-rs here removes the C dependency entirely and unifies on the backend already in use elsewhere in the tree.
  • cargo update -p flate2 was needed since the lockfile still had the pre-zlib-rs 1.0.28 release pinned; it resolved to 1.1.10, dropping cmake and libz-ng-sys from the dependency tree and adding zlib-rs, miniz_oxide, adler2, and simd-adler32 (all pure Rust).
  • Bumped the crate version 0.12.8 → 0.12.9.

Test plan

  • cargo test --lib — 37 passed, 0 failed
  • cargo build --release — clean (only pre-existing, unrelated warnings)
  • cargo check --all-targets — clean

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com

flate2's zlib-ng feature pulls in libz-ng-sys, which compiles zlib-ng's
C source via CMake. On BinaryBuilder's aarch64-apple-darwin toolchain
(Clang 22), this fails: zlib-ng's CMake ARMv8 CRC32 feature-detection
incorrectly concludes the compiler lacks native __crc32b/__crc32h/
__crc32w intrinsics, so it includes its own polyfill header
(acle_intrins.h) -- which then collides with Clang's own arm_acle.h,
which already defines them, producing "redefinition of '__crc32b'"
compile errors.

zlib-rs (a pure-Rust zlib reimplementation, no C compiler needed) is
already used elsewhere in this same dependency graph -- parquet (via
iceberg-rust, a downstream consumer of this crate through
iceberg_rust_ffi) enables flate2's zlib-rs feature. Before this change
both backends were being compiled into the same binary simultaneously,
which flate2's own documentation flags as producing undefined ordering
behavior when more than one backend is enabled at once. Switching to
zlib-rs here removes the C dependency entirely and unifies on the
backend already in use.

`cargo update -p flate2` was needed since the lockfile still had the
pre-zlib-rs 1.0.28 release pinned; it resolved to 1.1.10, dropping
`cmake` and `libz-ng-sys` from the dependency tree and adding `zlib-rs`,
`miniz_oxide`, `adler2`, and `simd-adler32` (all pure Rust).

Verified: `cargo test --lib` (37 passed), `cargo build --release`,
both clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@gbrgr
gbrgr merged commit bbbbd2f into main Aug 28, 2026
4 checks passed
@gbrgr
gbrgr deleted the gb/flate2-zlib-rs branch August 28, 2026 08:23
gbrgr added a commit to RelationalAI/RustyIceberg.jl that referenced this pull request Aug 28, 2026
## Summary

- Points at
[RelationalAI/object_store_ffi@2031546](RelationalAI/object_store_ffi@2031546)
([object_store_ffi#48](RelationalAI/object_store_ffi#48),
still open as of this PR), which switches `object_store_ffi`'s `flate2`
dependency from the `zlib-ng` backend to `zlib-rs` (pure Rust, no C
compiler needed).
- `zlib-ng` was failing to cross-compile on BinaryBuilder's
`aarch64-apple-darwin` toolchain: `zlib-ng`'s CMake ARMv8 CRC32
feature-detection incorrectly concluded Clang 22 lacks native
`__crc32b`/`__crc32h`/`__crc32w` intrinsics, so it included its own
polyfill header, which then collided with Clang's own `arm_acle.h`
(which already defines them) — `redefinition of '__crc32b'` errors.
Found while bumping `iceberg_rust_ffi_jll` in Yggdrasil
([JuliaPackaging/Yggdrasil#14575](JuliaPackaging/Yggdrasil#14575)).
- This also removes a latent issue: `parquet` (via `iceberg-rust`)
already uses `flate2`'s `zlib-rs` backend, so both `zlib-ng` and
`zlib-rs` were being compiled into the same binary simultaneously —
`flate2`'s own docs flag enabling more than one backend at once as
producing undefined ordering behavior.
- Bumps `iceberg_rust_ffi`'s own version 0.9.1 → 0.9.2 (its `Cargo.toml`
changed) and `Project.toml` to match.

⚠️ This PR's `rev` will need to be updated to the merge commit once
`object_store_ffi#48` lands on its `main`, same as the pattern used for
the `iceberg-rust` bump in #110.

## Test plan

- [x] `cargo test` (iceberg_rust_ffi) — 40 passed, 0 failed
- [x] `cargo clippy --all-targets -- -D warnings` / `cargo fmt --all --
--check` — clean
- [x] `make test-dev` — **27935 passed, 0 failed, 0 errored**, fully
green, including the GZIP compression test (exercising the new `zlib-rs`
backend path)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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 this pull request may close these issues.

1 participant