Re: ld compat linker warnings considered harmful
Thomas Klausner <[email protected]>
| Newsgroups | gmane.os.netbsd.devel.toolchain |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Aug 19, 2026 at 04:18:40AM +0100, David Holland wrote: > On Tue, Aug 18, 2026 at 09:58:58AM +0200, Thomas Klausner wrote: > > ld: /usr/lib/libm.so.0: warning: warning: reference to compatibility cabs() > > > > The (known) problem is that this linker warning also triggers when it > > shouldn't, when libraries are pulled in indirectly and the functions > > not even used by the program that (indirectly) links against them. > > Is there a description of the problem somewhere? Every one of these I > remember seeing in pkgsrc and getting around to actually investigating > (all years ago now, admittedly) turned out to be real. I last asked about this in February https://mail-index.netbsd.org/current-users/2026/02/24/msg047412.html > So I'm not convinced meson is doing the wrong thing. But having things > break obviously won't do. and included a short example that shows it's a real problem, and Joerg confirmed it. https://mail-index.netbsd.org/current-users/2026/02/25/msg047416.html I'll include it again. In short, a program just doing 'exit' is linked against libgssapi (or libroken, both work), and the linker complains: # gcc -o a a.c -lgssapi ld: /usr/lib/libutil.so.7: warning: warning: reference to compatibility login_getpwclass(); include <login_cap.h> for correct reference ld: /usr/lib/libutil.so.7: warning: warning: reference to compatibility pw_scan(); include <pwd.h> to generate correct reference ld: /usr/lib/libutil.so.7: warning: warning: reference to compatibility loginx(); include <util.h> to generate correct reference ld: /usr/lib/libutil.so.7: warning: warning: reference to compatibility parsedate(); include <util.h> for correct reference ld: /usr/lib/libutil.so.7: warning: warning: reference to compatibility pw_copyx(); include <util.h> to generate correct reference ld: /usr/lib/libutil.so.7: warning: warning: reference to compatibility pw_getpwconf(); include <pwd.h> to generate correct reference ld: /usr/lib/libutil.so.7: warning: warning: reference to compatibility login(); include <util.h> to generate correct reference ld: /usr/lib/libutil.so.7: warning: warning: reference to compatibility setusercontext(); include <login_cap.h> for correct reference ld: /usr/lib/libutil.so.7: warning: warning: reference to compatibility pw_copy(); include <util.h> to generate correct reference No function from gssapi (or roken) is called, so nothing can call libutil and need the compat header. Thomas
a.c
(text/x-c, 45 B)
#include <stdlib.h>
int main() {
exit(0);
}
Makefile
(text/plain, 51 B)
a: gcc -o a a.c -lgssapi b: gcc -o b a.c -lroken