--as-needed by default

Zack Weinberg zack@codesourcery.com
Thu Mar 3 23:41:00 GMT 2005


Alan Modra <amodra@bigpond.net.au> writes:

> On Thu, Mar 03, 2005 at 02:30:11PM +0000, Mike Hearn wrote:
>> I'm wondering why the --as-needed ld option is not used by default.
>
> Code supporting --as-needed is relatively new and quite complicated.
> It is likely to have bugs.  Also, some projects might rely on the
> existing ld behaviour of always adding DT_NEEDED tags for shared
> libraries.

I've argued in the past for --as-needed to be the default, because it
makes shared library semantics match static library semantics, and
because it takes a quite contrived application to depend on DT_NEEDEDs
for libraries that satisfy no symbols. (You would need a library that
did something useful, e.g. via a global constructor, just by being
linked into your application, even if you referenced no symbols from it.)

However, Alan's concerns are valid, especially the "it's new and
complicated and might be buggy" ones.  Is this apropos the thread on
ubuntu-devel?  If so, why don't y'all change the default, rebuild the
whole distro, and see what breaks?  If you find bugs, then they can be
fixed, and if you find that nothing breaks, that'll be solid evidence
that making --as-needed the default is safe.

zw



More information about the Binutils mailing list