LDFLAGS in krb5-config --libs, but not in pkg-config

Andreas Hasenack andreas at canonical.com
Sat Apr 30 10:19:32 EDT 2022


Hi,

straight to the point, should $LDFLAGS be part of `krb5-config
--libs`? It's not in the equivalent `pkg-config krb5 --libs` output.

On an Ubuntu system, for example, this returns the library path, the
libraries that are needed, and special linked options (LDFLAGS):
$ krb5-config --libs
-L/usr/lib/x86_64-linux-gnu/mit-krb5 -Wl,-Bsymbolic-functions
-flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -lkrb5 -lk5crypto
-lcom_err

But pkg-config only shows the library path and the actual libraries
that are needed:
$ pkg-config krb5 --libs
-L/usr/lib/x86_64-linux-gnu/mit-krb5 -lkrb5 -lk5crypto -lcom_err


This came up because in Ubuntu we add some default linker flags to all builds:

$ dpkg-buildflags --get LDFLAGS
-Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro

Debian does so too:
# dpkg-buildflags --get LDFLAGS
-Wl,-z,relro

But sometimes some packages don't build correctly with such flags. One
example I have in Ubuntu is autofs, which doesn't work correctly when
-Wl,-Bsymbolic-functions is used. Or mariadb, which fails to catch an
exception when -lto is used. In such cases, we remove these flags from
the build.

Upon inspection of build logs, however, we still see that in some
specific linker calls, the flags are present. Further investigation
led us to krb5-config exposing them via --libs, and the build process
at some point calls krb5-config --libs to find out which libraries
should be used. But that is introducing LDFLAGS that were used when
krb5 was built, and reintroducing the linker options we disabled
specifically for this other package.


More information about the krbdev mailing list