Subject: how to deal with libc vs. libresolve discrepancies?
To: NetBSD User-Level Technical Discussion List <tech-userlevel@NetBSD.org>
From: Greg A. Woods <woods@weird.com>
List: tech-pkg
Date: 12/18/2006 13:01:58
--pgp-sign-Multipart_Mon_Dec_18_13:01:52_2006-1
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable
This problem perhaps only affects deprecated releases (though if I'm
lucky it also affects 2.0 :-)) and of course it only shows up when
static linking binaries. It's been bugging me for nearly a decade now
though. It may even be somehow specific to the releases I build, though
if so it's been a long-standing issue and somehow it's been resolved in
the netbsd-3 branch even though I'm still building my releases in the
same way. More likely though it's got something to do with the upgrade
of libresolv in the newer releases.
So, here's what happens, this example from net/lft. In the past I've
just blasted in and patched the errant config script or makefile to get
rid of the problem-causing unnecessary "-lresolv", and sometimes I think
I've even submitted a patch and/or PR, thus the cross-post to tech-pkg.
configure:3906: checking for pcap_lookupdev in -lpcap
configure:3939: cc -o conftest -O2 -mno-soft-float -mcpu=3D21164a -g -mieee=
-pipe -mieee -I/usr/include -I/usr/include -static -L/usr/lib -Wl,-R/usr/p=
kg/lib conftest.c -lpcap -lm -lresolv >&5
/usr/lib/libc.a(res_query.o): In function `res_querydomain':
/building/work/woods/m-NetBSD-1.6/lib/libc/net/res_query.c:331: multiple de=
finition of `res_querydomain'
/usr/lib/libresolv.a(res_query.o):/building/work/woods/m-NetBSD-1.6/lib/lib=
resolv/../libc/net/res_query.c:331: first defined here
ld: Warning: size of symbol `res_querydomain' changed from 448 to 496 in re=
s_query.o
/usr/lib/libc.a(res_mkquery.o): In function `__res_opt':
/building/work/woods/m-NetBSD-1.6/lib/libc/net/res_mkquery.c:208: multiple =
definition of `__res_opt'
/usr/lib/libresolv.a(res_mkquery.o):/building/work/woods/m-NetBSD-1.6/lib/l=
ibresolv/../libc/net/res_mkquery.c:208: first defined here
Why does this actually happen (even though the libc and libresolv code
are both built from the same sources)?
Is the only "fix" to work around it on older releases (as I've always
done) and wait until at least I'm running everythere and everything on
netbsd-3?
Can anyone confirm whether or not static linking of resolv(3)
applications libresolv.a works on netbsd-2 systems (I have no such box
to test on). One application that might be easy to test with would be
"net/host". Just build it normally then re-run the final link command
manually with "-static" and "-lresolv" in the command line:
# cd work/host-*
# cc -static [...cut&paste...] -lresov
When doing this I see errors about multiple definitions of __res_opt.
Once I even tried figuring out what symbol was pulling this in from
libresolv that wasn't already found in libc, especially since dropping
the "-lresolv" solves the problem without leaving anything undefined,
but I couldn't find it. The damn GNU linker is way too complicated.
--=20
Greg A. Woods
H:+1 416 218-0098 W:+1 416 489-5852 x122 VE3TCP RoboHack <woods@robohack.ca>
Planix, Inc. <woods@planix.com> Secrets of the Weird <woods@weird.com>
--pgp-sign-Multipart_Mon_Dec_18_13:01:52_2006-1
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
MessageID: cWKutF/S3QuzrFCyG8DFwOW4gXfOx48j
iQA/AwUBRYbXlWJ7XxTCWceFEQKP8gCgt+LJZy/tItzowM85g++EWSJUfIkAoKAW
cxDXgDXm0Dc4VFHMzYxTr96p
=3keu
-----END PGP SIGNATURE-----
--pgp-sign-Multipart_Mon_Dec_18_13:01:52_2006-1--