dmd's linking order

Marco Leise Marco.Leise at gmx.de
Wed Apr 11 22:49:42 PDT 2012


Am Wed, 11 Apr 2012 14:51:14 -0400
schrieb "Nick Sabalausky" <SeeWebsiteToContactMe at semitwist.com>:

> "Steven Schveighoffer" <schveiguy at yahoo.com> wrote in message 
> news:op.wcln1rh9eav7ka at localhost.localdomain...
> >
> > I'm not a linker expert, but I found this page which describes the changes 
> > and the reasoning:
> >
> > See this post: https://wiki.ubuntu.com/NattyNarwhal/ToolchainTransition
> >
> 
> That says the order-dependent  behavior is caused by --as-needed being 
> default. I'm no linker expert either, but the description of the purpose 
> of --as-needed sounds...goofy and pointless (although maybe it makes sense 
> for C's lack of a proper module system?).
> 
> It can be disabled, apperently, by using --no-as-needed. That page tries to 
> discourage people from doing that though, but the reason it gives seems 
> vague. Personally, I'd wonder whether going along with --as-needed is really 
> even worth doing. (Of course, if it turns out to be easy to fix the 
> ordering, then we may as well.)

I didn't know that --as-needed causes so much trouble. We've been using it on Gentoo a while before Ubuntu made that step and I know it took a while (~a year) until all packages would compile with it.
The problem that this solved was that libraries and applications are linked to other libraries they don't actually call into. On a long stream of dependencies an application would dynamically load way more libraries than it actually uses, increasing the start time. So the linker lacked the intelligence to filter out unnecessary libraries before.
Since there are some cases, where you must link to a library anyway, you can put --no-as-needed in front of them. Look at the positive side: You can now by default link against all libraries on your system without bloating the executable! :)

-- 
Marco



More information about the Digitalmars-d mailing list