Date: Sat, 15 Dec 2012 13:07:54 +0200 From: Konstantin Belousov <kostikbel@gmail.com> To: Baptiste Daroussin <bapt@freebsd.org> Cc: hackers@freebsd.org Subject: Re: Fix overlinking in base aka import pkgconf Message-ID: <20121215110754.GV71906@kib.kiev.ua> In-Reply-To: <20121215105643.GG18884@ithaqua.etoilebsd.net> References: <20121214235418.GF18884@ithaqua.etoilebsd.net> <20121215012233.GP71906@kib.kiev.ua> <20121215105643.GG18884@ithaqua.etoilebsd.net>
next in thread | previous in thread | raw e-mail | index | archive | help
--9xA8aadJAx1hWuKz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Dec 15, 2012 at 11:56:43AM +0100, Baptiste Daroussin wrote: > On Sat, Dec 15, 2012 at 03:22:34AM +0200, Konstantin Belousov wrote: > > On Sat, Dec 15, 2012 at 12:54:19AM +0100, Baptiste Daroussin wrote: > > > Hi, > > >=20 > > > Some of our binary are overlinked, the way we handle the linking does= n't help > > > for that. > > What do you mean there ? Do you mean that some libraries specified for = the > > linking stage of the final binary are not needed for the execution ? >=20 > I mean some library are registrer in the binary with DT_NEEDED tag where = they > don't need to. >=20 > >=20 > > >=20 > > > On proposition could be to use pkgconf https://github.com/pkgconf/pkg= conf which > > > is BSD license pkg-config implementation 100% compatible with pkg-con= fig. > > >=20 > > > What I propose is to create a new PCADD variable for the Makefiles. > > >=20 > > > PCADD will invoke pkgconf to gather the libraries and the cflags for = a given > > > project. > > >=20 > > > The second thing would be to create .pc files for all of our librarie= s. > > >=20 > > > for example: > > > usr.bin/fstat dynamic build is overlinked > > And how this is better than just removing the unneeded library from > > the Makefile ? >=20 > In that case to statically build you need -lkvm -lutil -lprocstat but if = you > build dynamically you will only need -lproctast meaning you don't need to= be > directly linked to libutil and libkvm. This means a breakage of libutil w= ill > only have inpact on procstat and no more on fstat for example. >=20 > >=20 > > For the port consumption, I believe that the better solution is to prov= ide > > a pack of the .pc files describing base libraries, most likely as port. >=20 > Yeah the port is another thing which yes can probably be done that way. >=20 > >=20 > > Using .pc for the base system build is overkill, it does not add anythi= ng > > that cannot be accomplished by our existing build system. IMO. >=20 > Probably. > The thing is with pkgconf, fstat does not need to know that procstat > needs libkvm and libutil for static link, it just has to know it needs pr= ocstat > and pkgconf does all the magic. and pkgconf is really small (only 48k on = an > amd64 box) >=20 > Other solution would be to reinvent the same thing using our framework? > Maybe a LDSADD (LD STATIC ADD) to differenciate both? First, there is a linker flag, --as-needed, which does exactly what you want: it only registers the dso as a dependency using DT_NEEDED dynamic tag when there are real references from the linked object to the symbols in the dso. On the other hand, I am not a big fun of this feature. Dynamic linker is permissive for the main binary to reference a symbols in implicit dependencies of the explicit dependencies. If sudden change causes the main binary to start using a symbol from 'second order' dsos, you cause unneccessary complications there. More, recently there was a trend in the Linux world to disable the static linker from resolving symbols from the second order dsos. See the --no-add-needed and its recent switch in the newer ld. Overall, I like the fact that we explicitely list all depended base librari= es in the link command, for the base system. --9xA8aadJAx1hWuKz Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iQIcBAEBAgAGBQJQzFoJAAoJEJDCuSvBvK1B06QP+wfKvb/2Rt4Oaf7IA8HgOu28 B9ichNuUasraRhi4Kk9O+J2Q96O9jXr3m/dBv+MP6S+iJrMrfZaW9kEc/e4rWCeo hp0KIgb5Cq0/MnOOWXl/IVXu8ZDTFCJtVr/iQSBdOZINxYumImPSM9QuD6d0yttP tXzHY/aF/iaqgba0cY6esAz0Drf9TWTdg1HJtAx1uUInbM3Q3NpoEa/8xy7zEgUr 5WKoaFZbhBi0HUT1j9Xme6nC3wFpjj2lTC00gVIgtg+lYU6VxbKywuHtt1NOaRlX jXzN2x55KZ6Gq1lhN50Ku0ElubEA7F7WRO3NO+Ree5bxI1oX2Y4Oryo0AVfoGI9J GsHff+1of2MZlHP3XeQEczYAjjEn9kVSoi5NOn9uavZL7EEUe5nHxqyxbKouAaqF Oham0/et38i3RhfC7n2KkxGDRPSrRqWq3P2hQS1fr9LEMI4YoP7zlWh7JTiZIWdN RPDPGrcMwDqvUgqZA5QENBuzcQnrNVP1smHuggSWXutEfuBlyX+xaYjTUfcNYNqu WVElBratCGWAUlQYB9sdjKA1jV0XreCJ6LoFIK6VUBPUBmqi9X8IgXXfeZ7SgcYY kmeljICrP+Khu/2sXJoNEc69dmMe9qodOCqTrXjlyvBz1vbBBJwEBysqeaZcGNKF w1JN1JLdlC5oHbIi+7N7 =/Oaj -----END PGP SIGNATURE----- --9xA8aadJAx1hWuKz--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121215110754.GV71906>