Skip to content

Link zlib statically via libz-sys - #7

Merged
IvanUkhov merged 2 commits into
bodoni:mainfrom
atlowChemi:fix/static-zlib-linking
Apr 14, 2026
Merged

Link zlib statically via libz-sys#7
IvanUkhov merged 2 commits into
bodoni:mainfrom
atlowChemi:fix/static-zlib-linking

Conversation

@atlowChemi

Copy link
Copy Markdown
Contributor

Summary

  • Removed redundant .static_flag(true) calls from all cc::Build blocks in build.rs — the cc crate already produces static .a archives, so the flag was a no-op
  • Added libz-sys with features = ["static"] to Cargo.toml to ensure zlib is statically linked
  • Added use libz_sys as _ in src/lib.rs to guarantee the linker includes the static zlib for version1

Replace the redundant `.static_flag(true)` calls in the cc build
scripts with an explicit `libz-sys` dependency (with the `static`
feature), ensuring zlib is properly linked for version1.
@atlowChemi
atlowChemi force-pushed the fix/static-zlib-linking branch from de9bd31 to 9cd69b8 Compare April 13, 2026 10:23
@IvanUkhov

Copy link
Copy Markdown
Member

Thank you! What is the context? You found the build failing in some environment due to -lz missing?

Comment thread Cargo.toml Outdated
Comment thread build.rs Outdated
@atlowChemi

Copy link
Copy Markdown
Contributor Author

Thank you! What is the context? You found the build failing in some environment due to -lz missing?

Yes, I was trying to build cross-platform for a napi.rs addon, it was failing when trying to build with cargo-xwin

@IvanUkhov
IvanUkhov merged commit 4ba3a9b into bodoni:main Apr 14, 2026
5 checks passed
@atlowChemi
atlowChemi deleted the fix/static-zlib-linking branch April 14, 2026 10:54
@atlowChemi

Copy link
Copy Markdown
Contributor Author

Thanks @IvanUkhov!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants