From owner-freebsd-arch@FreeBSD.ORG Thu Nov 6 15:33:48 2014 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6ED5C725; Thu, 6 Nov 2014 15:33:48 +0000 (UTC) Received: from spindle.one-eyed-alien.net (spindle.one-eyed-alien.net [199.48.129.229]) by mx1.freebsd.org (Postfix) with ESMTP id 46E24E11; Thu, 6 Nov 2014 15:33:47 +0000 (UTC) Received: by spindle.one-eyed-alien.net (Postfix, from userid 3001) id EBFFF5A9F0B; Thu, 6 Nov 2014 15:33:40 +0000 (UTC) Date: Thu, 6 Nov 2014 15:33:40 +0000 From: Brooks Davis To: Baptiste Daroussin Subject: Re: Overlinking in base Message-ID: <20141106153340.GB76675@spindle.one-eyed-alien.net> References: <20141105113839.GG10388@ivaldir.etoilebsd.net> <20141105125431.GD53947@kib.kiev.ua> <20141105125931.GJ10388@ivaldir.etoilebsd.net> <20141105133029.GH53947@kib.kiev.ua> <20141105134006.GL10388@ivaldir.etoilebsd.net> <3912.1415233494@chaos> <20141106130555.GP10388@ivaldir.etoilebsd.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ZPt4rx8FFjLCG7dd" Content-Disposition: inline In-Reply-To: <20141106130555.GP10388@ivaldir.etoilebsd.net> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: Konstantin Belousov , arch@freebsd.org, "Simon J. Gerraty" X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Nov 2014 15:33:48 -0000 --ZPt4rx8FFjLCG7dd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 06, 2014 at 02:05:55PM +0100, Baptiste Daroussin wrote: > On Wed, Nov 05, 2014 at 04:24:54PM -0800, Simon J. Gerraty wrote: > > Baptiste Daroussin wrote: > > > In the second case we could do it via make(1) > > > LIBADD=3D liba libc libc > > > this will open something like a ${PATHTOTHELIB}/link.mk which will de= fine > > > DYNAMIC_ADD > > > STATIC_ADD > > >=20 > > > And this could be recursive. > >=20 > > We do something like that in the Junos build > >=20 > > prog makefile might have DPLIBS+=3D ${LIBFOO} > > which is exactly equivalent to > >=20 > > LDADD+=3D -lfoo > > DPADD+=3D ${LIBFOO} > >=20 > > but ensures that they stay in sync (not so important now with meta > > mode). > >=20 > > bsd.libnames.mk can then have > >=20 > > DPLIBS_libfoo +=3D ${LIBGOO} > > DPLIBS_libgoo +=3D ${LIBZOO} > >=20 > > All of which is processed by dpadd.mk which you can find in > > contrib/bmake/mk > > Though dpadd.mk ignores DPLIBS_libgoo +=3D ${LIBZOO} if LIBZOO has alre= ady > > been added. > >=20 > I'am about to add something based on the following principle: > https://people.freebsd.org/~bapt/plop.diff >=20 > With a bit more changes >=20 > The version I have now (a bit different from the patch now :)) allows mul= tiple > things: >=20 > 1/ simplify the Makefile for users: > LIBADD=3D m archive util > instead of > DPADD=3D ${LIBM} ${LIBARCHIVE} ${LIBUTIL} > LDADD=3D -lm -larchive -lutil For the list, the reason I proposed LIBADD=3Dfoo initially vs the DPLIBS model is that I need the library name is a format I can use for other things such as linking programs to a combination of an archive containing native code and a collection of llvm bitcode. In the tesla branch in perforce I'm using this to perform whole program analysis. I use this snipit to add entries to both llvm-link command line and the final ld comamnd. +.if ${MK_LLVM_INSTRUMENTED} !=3D "no" +LLVM_LINK_ADD+=3D ${LIBADD:@L@${LLVM_IR_FILE_${L:tu}:U"No LLVM_IR_F= ILE_${L:tu} variable defined"}@} +LLVM_LDADD+=3D ${LIBADD:@L@${LLVM_IR_FILE_${L:tu}:U"No LLVM_NATIVE_FILE_= ${L:tu} variable defined"}@} +.endif Thinking about this in the context of overlinking. There's an argument we should use LIBADD to produce an _LIBADD which is a pure list of actual libraries to be linked so uses like this can use it. That would also provide a place to do sorting hacks if required. -- Brooks --ZPt4rx8FFjLCG7dd Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlRblNQACgkQXY6L6fI4GtRBTACgyw/ih1IJNtIPj+WrbkvUfx9J PAsAoMGipViAAobjES31kZUxZaAuzoks =MlnA -----END PGP SIGNATURE----- --ZPt4rx8FFjLCG7dd--