NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

toolchain/61079: ld compat linker warnings considered harmful



>Number:         61079
>Category:       toolchain
>Synopsis:       ld compat linker warnings considered harmful
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 25 20:00:00 +0000 2026
>Originator:     Thomas Klausner
>Release:        NetBSD 11.99.11
>Organization:
	
>Environment:
	
	
Architecture: x86_64
Machine: amd64
>Description:
For library function renaming to work, NetBSD uses header macros to
use the latest version of a function, so that the old symbol still
stays available for programs that were linked against the previous
version of the function.

There is also a linker warning so that you do not use the old
functions by accident, because you forgot including the header, e.g.:

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.

meson by default enables fatal linker warnings, so this breaks
builds.

I've discussed this on the mailing lists twice, without results,
so let's file it so it's at least a well-documented problem.

https://mail-index.netbsd.org/current-users/2026/02/24/msg047412.html

https://mail-index.netbsd.org/tech-toolchain/2026/08/18/msg004873.html

>How-To-Repeat:
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.

a.c
--- begin ---
#include <stdlib.h>
int main() {
        exit(0);
}
--- end ---

Makefile
--- begin ---
a:
        gcc -o a a.c -lgssapi
b:
        gcc -o b a.c -lroken
--- end ---
>Fix:
Not known.

RVP pointed out that --no-copy-dt-needed-entries seems to work around this:

https://mail-index.netbsd.org/tech-toolchain/2026/09/18/msg004903.html

but I don't know if that's an appropriate solution or not.

>Unformatted:
 	
 	



Home | Main Index | Thread Index | Old Index