Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: use pkg-config to find zlib #41

Closed
wants to merge 1 commit into from
Closed

Conversation

orbea
Copy link

@orbea orbea commented Mar 8, 2024

When building with slibtool it fails with undefined references for -lz because the build sets -no-undefined in the LDFLAGS. This doesn't fail with GNU libtool because they silently ignore -no-undefined.

To solve this the build now uses PKG_CHECK_MODULES to find zlib.

Gentoo issue: https://bugs.gentoo.org/920273

When building with slibtool it fails with undefined references for
-lz because the build sets -no-undefined in the LDFLAGS. This doesn't
fail with GNU libtool because they silently ignore -no-undefined.

To solve this the build now uses PKG_CHECK_MODULES to find zlib.

Gentoo issue: https://bugs.gentoo.org/920273
@orbea
Copy link
Author

orbea commented Mar 8, 2024

I only now see the similar already existing PR...

#32

I'll leave this open for visibility, but I don't mind which version is preferred.

@tillkamppeter
Copy link
Member

Merged pull request #32. Thanks for the reminder by this pull request.

@eli-schwartz
Copy link
Contributor

eli-schwartz commented Mar 8, 2024

Note the fairly obvious difference between my PR and this later one is that mine included fallback code for when zlib is installed by the host system without a pkg-config file, e.g. some versions of *BSD that include it in their monorepo without building via the official zlib build system.

EDIT:

This doesn't fail with GNU libtool because they silently ignore -no-undefined.

The libtool flag is unrelated to the ld.bfd flag, and libtool behaves exactly as you want it to if you add -Wl,--no-undefined to LDFLAGS.

@orbea orbea deleted the zlib branch March 8, 2024 14:08
@orbea
Copy link
Author

orbea commented Mar 8, 2024

The libtool flag is unrelated to the ld.bfd flag, and libtool behaves exactly as you want it to if you add -Wl,--no-undefined to LDFLAGS.

FWIW, Darwin doesn't have-Wl,--no-undefined and instead expects -Wl,-undefined,error. I am unsure what GNU libtool does on Darwin, but slibtool respects -no-undefined on both platforms.

@eli-schwartz
Copy link
Contributor

The libtool flag is unrelated to the ld.bfd flag, and libtool behaves exactly as you want it to if you add -Wl,--no-undefined to LDFLAGS.

FWIW, Darwin doesn't have-Wl,--no-undefined and instead expects -Wl,-undefined,error. I am unsure what GNU libtool does on Darwin, but slibtool respects -no-undefined on both platforms.

GNU libtool documents the flag as meaning "it is safe or not safe to build shared libraries in a cygwin environment".

When I say it doesn't have anything to do with the ld.bfd flag, I'm not exaggerating. It is literally unrelated. It is not topical to the topic of asking the linker to error out on undefined symbols.

@orbea
Copy link
Author

orbea commented Mar 8, 2024

I don't know what you mean by "ld.bfd", -no-undefined is a libtool flag which passes the appropriate flag to the system's linker such as -Wl,--no-undefined. GNU libtool for a very long time simply does nothing on most platforms (?) while slibtool will actually use the appropriate linker flag which finds issues like this that have previously gone unnoticed.

There may also be issues with using -Wl,--no-undefined on OpenBSD when building a library.

https://bugs.freedesktop.org/show_bug.cgi?id=76856
https://marc.info/?l=openbsd-tech&m=170284912609821&w=2

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