From owner-freebsd-hackers@FreeBSD.ORG Sun Dec 16 13:01:11 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 DD3EE247; Sun, 16 Dec 2012 13:01:11 +0000 (UTC) (envelope-from jlh@FreeBSD.org) Received: from smtp5-g21.free.fr (smtp5-g21.free.fr [IPv6:2a01:e0c:1:1599::14]) by mx1.freebsd.org (Postfix) with ESMTP id 859198FC13; Sun, 16 Dec 2012 13:01:08 +0000 (UTC) Received: from endor.tataz.chchile.org (unknown [82.233.239.98]) by smtp5-g21.free.fr (Postfix) with ESMTP id 3E061D480FD; Sun, 16 Dec 2012 14:01:02 +0100 (CET) Received: from felucia.tataz.chchile.org (felucia.tataz.chchile.org [192.168.1.9]) by endor.tataz.chchile.org (Postfix) with ESMTP id 207BE1E6; Sun, 16 Dec 2012 14:01:01 +0100 (CET) Received: by felucia.tataz.chchile.org (Postfix, from userid 1000) id F1F821005E; Sun, 16 Dec 2012 13:01:00 +0000 (UTC) Date: Sun, 16 Dec 2012 14:01:00 +0100 From: Jeremie Le Hen To: Baptiste Daroussin Subject: Re: Fix overlinking in base aka import pkgconf Message-ID: <20121216130100.GD15112@felucia.tataz.chchile.org> Mail-Followup-To: Baptiste Daroussin , Konstantin Belousov , hackers@freebsd.org References: <20121214235418.GF18884@ithaqua.etoilebsd.net> <20121215012233.GP71906@kib.kiev.ua> <20121215105643.GG18884@ithaqua.etoilebsd.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121215105643.GG18884@ithaqua.etoilebsd.net> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Konstantin Belousov , 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: Sun, 16 Dec 2012 13:01:12 -0000 Hi bapt, kib, 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, > > > > > > Some of our binary are overlinked, the way we handle the linking doesn'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 ? > > I mean some library are registrer in the binary with DT_NEEDED tag where they > don't need to. > > > > > > > > > On proposition could be to use pkgconf https://github.com/pkgconf/pkgconf which > > > is BSD license pkg-config implementation 100% compatible with pkg-config. > > > > > > What I propose is to create a new PCADD variable for the Makefiles. > > > > > > PCADD will invoke pkgconf to gather the libraries and the cflags for a given > > > project. > > > > > > The second thing would be to create .pc files for all of our libraries. > > > > > > for example: > > > usr.bin/fstat dynamic build is overlinked > > And how this is better than just removing the unneeded library from > > the Makefile ? > > 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 will > only have inpact on procstat and no more on fstat for example. I think this could be solved by an implicit linker script contained in .so and .a files, pointing to the real libraries. We have already the SHLIB_LDSCRIPT variable to accomplish this for .so files. It may be possible to do the same for .a files, though this would require renaming the real archives to something like .a.0 (here I'm just taking a similar scheme to the one used for DSO). As a matter of fact, libprocstat.a would contain: GROUP ( /usr/lib/libprocstat.a.0 /usr/lib/libkvm.a /usr/lib/libutil.a ) Note that libkvm.a and libutil.a could be linker scripts as well. Kib, do you see any problem to this proposition? -- Jeremie Le Hen Scientists say the world is made up of Protons, Neutrons and Electrons. They forgot to mention Morons.