PSA: libz-sys on musl no longer links statically by default (unless cross-compiling)

If you're using libz-sys (either directly, or indirectly through something like the flate2 or git2 crates), and you want to statically link libz-sys on musl, you should now specify the static feature flag for libz-sys explicitly.

Previously, libz-sys would always assume static linking on musl. This caused problems for people running native musl toolchains (such as on musl-based distributions). Now, libz-sys will link dynamically to a system zlib if available, if you're not cross-compiling.

Note that if you're cross-compiling to a musl-based target from another target, libz-sys will still build and statically link zlib for the target you're compiling to, so this won't break cross-compiled builds. However, if you're depending on static linking, you should still add the static feature flag to libz-sys, for the benefit of people building natively on musl toolchains.

I've also posted this announcement to https://www.reddit.com/r/rust/comments/n43pcb/psa_libzsys_on_musl_no_longer_links_statically_by/ .

3 Likes