Skip to content

Add -lz when PHOBOS_SYSTEM_ZLIB=on and -link-defaultlib-shared#4963

Merged
thewilsonator merged 1 commit intoldc-developers:masterfrom
the-horo:zlib-link-always
Aug 3, 2025
Merged

Add -lz when PHOBOS_SYSTEM_ZLIB=on and -link-defaultlib-shared#4963
thewilsonator merged 1 commit intoldc-developers:masterfrom
the-horo:zlib-link-always

Conversation

@the-horo
Copy link
Copy Markdown
Contributor

@the-horo the-horo commented Aug 3, 2025

Some projects use the zlib C function directly and, given that those symbols are available when phobos embeds zlib (the default) and when linking the stdlib statically, the projects often don't include a -lz in their build settings. This omission then prevents a successful build with PHOBOS_SYSTEM_ZLIB=on and
-link-defaultlib-shared.

Until a permanent decision is made if those projects should change their build scripts or if the compiler should always add -lz, add the library anyway, to minimize breakages.

This also makes the behavior consistent with gdc which also adds an unconditional -lz when zlib is not embedded.

See-Also: #4742

Some projects use the zlib C function directly and, given that those
symbols are available when phobos embeds zlib (the default) and when
linking the stdlib statically, the projects often don't include a
`-lz` in their build settings. This omission then prevents a
successful build with PHOBOS_SYSTEM_ZLIB=on and
-link-defaultlib-shared.

Until a permanent decision is made if those projects should change
their build scripts or if the compiler should always add `-lz`, add
the library anyway, to minimize breakages.

This also makes the behavior consistent with gdc which also adds an
unconditional `-lz` when zlib is not embedded.

See-Also: ldc-developers#4742
Signed-off-by: Andrei Horodniceanu <[email protected]>
@the-horo
Copy link
Copy Markdown
Contributor Author

the-horo commented Aug 3, 2025

ping @schveiguy

@thewilsonator thewilsonator merged commit 9db6d95 into ldc-developers:master Aug 3, 2025
18 checks passed
@schveiguy
Copy link
Copy Markdown
Contributor

Thanks!

@the-horo the-horo deleted the zlib-link-always branch August 27, 2025 19:26
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.

3 participants