tech-toolchain archive

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

Re: ld compat linker warnings considered harmful



On Wed, 19 Aug 2026, Thomas Klausner wrote:

I last asked about this in February

https://mail-index.netbsd.org/current-users/2026/02/24/msg047412.html
[...]
and included a short example that shows it's a real problem, and Joerg
confirmed it.
[...]
# 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.


I don't get this error at all. The only function that libroken's using from
libutil is pidfile(3), so why are those warning being triggered. The ld(1)
docs clearly state[1]:

```
.gnu.warning.SYM

    The contents of any section whoes name starts with the prefix
    ʽ.gnu.warning.ʼ and then finishes with the name of a symbol is
    treated in a similar fashion to the ʽ.gnu.warningʼ section,
    but only if the named symbol is referenced. So for example the
    contents of a section called ʽ.gnu.warning.fooʼ will be displayed
    as warning message if, and only if, the symbol ʽfooʼ is referenced
    by one or more of the input files. This includes object files
    pulled in from static libraries, shared objects needed to
    complete the link and so on.
```

[1]: https://sourceware.org/binutils/docs/ld.html#Special-Sections

and, that's how this behaves on Linux (binutils-2.44 on Debian 13.6, and
binutils-2.42 on Ubuntu 24.04).

Looks like a NetBSD-specific issue. I think you can file a (NetBSD) PR for this
one, Thomas.

-RVP

PS. test code below for those wanting to fiddle with this. Also presents a
workaround using a linker script, but which, I think, would be too intrusive
for NetBSD right now (not that it's a bad idea in general--see PR lib/57615).

```
base64 ld-gnu-warning.tar.gz
H4sIAAAAAAAAA+1YW2/aMBTOK/4VR1CpZCJpriAxdS97WaWt42HTNG2TFRIDVoODktASTfvvs3EI
gXZlDwFU1Z9Egp3jYyfH37k4jowpWxoPQcoom15px4DFMbAscbcH/s59A832Hc/2XM8aeJplO7Zl
a+AfZTV7WGZ5kAJo6f3iWblDz18o4l37F+as+TmEgfvP2d/tb+zv9n1H2J+3NLCaX8pjvHL7U5ZD
Udjd+4RG+lskm86mee7VKRwbe/wX98ZdwCH+O36N/47P+e86zkDx/xToRGRCGQEcU3aHy23QzYr5
OIl7MM+mOvxEwME/U05DCBOW5RDO+DeL6XicRZjMab4zGnc6cvyPX+VYAYyDPE/peJkTjLtdjJcZ
iTDuYZyRMKcJ471tk+9Fs1RjtqHUo+s6XIu1KH/UOPb4/ym44/shJo3OcYj/fd/by/9cnz9W/D8B
5gFlQxBXM4SVOROsXplZYtqoFYZgLCgBI1kLbKSMjxcX3cVDpIMRr8D4FveMdBHks+uyG6FKx5Cr
lGoLqbqoqc64EyERGJPRzXsxRzVqPag+S/HULK2YcR2T2rDyH2p14KB+IUTCWQKXN7ejr1+624d8
Ov0S3lXaULXsIX+LcP0mMkz+8zWkuJCur7KoVlms9ZqjD59vvw8hjEnA0Po6RK10zlXBGzPhv0xe
+CDx6Y/i/fb4L03c8ByH+M/T/Sr++96a//bAUfw/BTqUhfEyItDmLG2jqyvY9hSiR5QESGwLWROg
36jFhUSdQHlQFrUCrxNaKcmXKYOVaPxRYfrl4FH93zT5tf/I/61a/u8NZP2v+H8SPMX26jxAkL1k
tiV4jbbSMgK20W7dwN1Bj2sSTgFoBsk4S2KSk7Y8WUDVyUJNsa0cxjmxx//VWc7/bL/Gf1fyX+X/
J4EI5Ct13Pdq8Yj/Z4j/tuVs+e/K+G+7iv+nwBPxf+MPnk/1RZKgkn0FBQUFBQUFBQWFF4W/skvX
HAAoAAA=
```


Home | Main Index | Thread Index | Old Index