Overlinking in base
Warner Losh
imp at bsdimp.com
Thu Nov 6 14:35:38 UTC 2014
On Nov 6, 2014, at 6:05 AM, Baptiste Daroussin <bapt at freebsd.org> 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
>
> 2/ ensure dependencies are automatically tracked
> For example -lucl needs -lm adding LIBADD= ucl does the magic by itself
>
> 3/ allow to build any single binary statically so far I'm able to build
> everything is bin sbin usr.bin and usr.sbin statically (which wasn't doable
> before)
>
> 3/ hides the private/internal lib from the final user
> Do more need to say USEPRIVATELIB because I do use a libunbound it is automatic
Generally I like this.
One issue though about dependencies: Is there a tool to manage them? How do we know if things are wrong?
Will a simple buildworld always detect that, or do we need to do a buildworld with static linking?
Warner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20141106/3732303c/attachment.sig>
More information about the freebsd-arch
mailing list