Overlinking in base

Brooks Davis brooks at freebsd.org
Thu Nov 6 15:33:48 UTC 2014


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 <bapt at freebsd.org> wrote:
> > > In the second case we could do it via make(1)
> > > LIBADD=	liba libc libc
> > > this will open something like a ${PATHTOTHELIB}/link.mk which will define
> > > DYNAMIC_ADD
> > > STATIC_ADD
> > > 
> > > And this could be recursive.
> > 
> > We do something like that in the Junos build
> > 
> > prog makefile might have DPLIBS+= ${LIBFOO}
> > which is exactly equivalent to
> > 
> > LDADD+= -lfoo
> > DPADD+= ${LIBFOO}
> > 
> > but ensures that they stay in sync (not so important now with meta
> > mode).
> > 
> > bsd.libnames.mk can then have
> > 
> > DPLIBS_libfoo += ${LIBGOO}
> > DPLIBS_libgoo += ${LIBZOO}
> > 
> > All of which is processed by dpadd.mk which you can find in
> > contrib/bmake/mk
> > Though dpadd.mk ignores DPLIBS_libgoo += ${LIBZOO} if LIBZOO has already
> > been added.
> > 
> I'am about to add something based on the following principle:
> https://people.freebsd.org/~bapt/plop.diff
> 
> With a bit more changes
> 
> The version I have now (a bit different from the patch now :)) allows multiple
> things:
> 
> 1/ simplify the Makefile for users:
> LIBADD= m archive util
> instead of
> DPADD= ${LIBM} ${LIBARCHIVE} ${LIBUTIL}
> LDADD= -lm -larchive -lutil

For the list, the reason I proposed LIBADD=foo 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} != "no"
+LLVM_LINK_ADD+=        ${LIBADD:@L@${LLVM_IR_FILE_${L:tu}:U"No LLVM_IR_FILE_${L:tu} variable defined"}@}
+LLVM_LDADD+=   ${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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20141106/42dd0c2f/attachment.sig>


More information about the freebsd-arch mailing list