Wireshark-dev: Re: [Wireshark-dev] Why are we linking with --as-needed?
From: Jeff Morriss <[email protected]>
Date: Thu, 21 Jan 2016 22:36:41 -0500
On 01/21/2016 10:17 PM, Guy Harris wrote:
The GNU linker documentation says of the --as-needed flag

	This option affects ELF DT_NEEDED tags for dynamic libraries mentioned on the command line after the --as-needed option. Normally the linker will add a DT_NEEDED tag for each dynamic library mentioned on the command line, regardless of whether the library is actually needed or not.  --as-needed causes a DT_NEEDED tag to only be emitted for a library that at that point in the link satisfies a non-weak undefined symbol reference from a regular object file or, if the library is not found in the DT_NEEDED lists of other needed libraries, a non-weak undefined symbol reference from another needed dynamic library. Object files or libraries appearing on the command line after the library in question do not affect whether the library is seen as needed. This is similar to the rules for extraction of object files from archives.  --no-as-needed restores the default behaviour.

--as-needed was added in this change:

	commit b6cffe405019da8259413cfcb829339712a098a7
	Author: Jörg Mayer <[email protected]>
	Date:   Fri Aug 7 18:49:24 2009 +0000

	    - Add an AC macro to test linker flags.
	    - Test whether the linker supports --as-needed and if so,
	      adds it to LDFLAGS

About all I could find for a reason were bugs such as


complaining that Wireshark didn't build with --as-needed.

So why is it useful that it be built - or, at least, buildable - with --as-needed?  (It's obviously not *necessary* as not all platform support that capability.)
I thought I remembered seeing (back around the time of bug 1677) a web 
page explaining why it was a Good Idea.  About all I can find at the 
moment is this one: