From owner-freebsd-hackers@FreeBSD.ORG Sat Dec 15 11:07:59 2012 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A22A4A3F; Sat, 15 Dec 2012 11:07:59 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id EB8E18FC14; Sat, 15 Dec 2012 11:07:58 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.5/8.14.5) with ESMTP id qBFB7skH036614; Sat, 15 Dec 2012 13:07:54 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.7.3 kib.kiev.ua qBFB7skH036614 Received: (from kostik@localhost) by tom.home (8.14.5/8.14.5/Submit) id qBFB7sKx036613; Sat, 15 Dec 2012 13:07:54 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 15 Dec 2012 13:07:54 +0200 From: Konstantin Belousov To: Baptiste Daroussin Subject: Re: Fix overlinking in base aka import pkgconf Message-ID: <20121215110754.GV71906@kib.kiev.ua> References: <20121214235418.GF18884@ithaqua.etoilebsd.net> <20121215012233.GP71906@kib.kiev.ua> <20121215105643.GG18884@ithaqua.etoilebsd.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="9xA8aadJAx1hWuKz" Content-Disposition: inline In-Reply-To: <20121215105643.GG18884@ithaqua.etoilebsd.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on tom.home Cc: hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Dec 2012 11:07:59 -0000 --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--