ld: /usr/lib/libutil.so.7: warning: warning: reference to compatibility ...

Thomas Klausner <[email protected]> Tue, 24 Feb 2026 21:41:03 +0100
Newsgroups gmane.os.netbsd.current
Message-ID <[email protected]>
Hi!

When compiling code in pkgsrc, I often see this block:

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

in code that doesn't use libutil at all.

This is a problem with code that is quite zealous and tries to use
-Wl,--fatal-warnings.

So I dug a bit and found that linking against libgssapi causes them as
well (which does not use libutil either), and digging deeper, I think
it's coming from libroken.

Minimal test case attached.

I think this is a bug, I'm just not sure if it's in ld or in the
warnings code (btw, it says "warning: warning: ") or somewhere else,
but it doesn't make sense to warn about this if the library is just
pulled in indirectly.
 Thomas
Makefile (text/plain, 51 B)
a:
	gcc -o a a.c -lgssapi
b:
	gcc -o b a.c -lroken
a.c (text/x-c, 45 B)
#include <stdlib.h>
int main() {
	exit(0);
}