From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-12-30 05:05:26
> Well, I also have some declarations like
> lib a : a.cpp : : : <library>foo ;
> It is probably has been superseded by
> lib a : a.cpp foo ;
> but still an acceptable option, so we should account for it as well.
Actually, the first declaration says that if you use 'a', you also need to use
'foo'. But it does not say that 'a' uses symbols from 'foo' -- so it's not
clear that there are any restriction on relative order on command line.
> >>After googling around for a while I found another solution, add -Wl,"-("
> >>in the beginning of the list of libraries and -Wl,"-)" at the end. This
> >>will make linker to repeatedly scan a group of libraries between the -(
> >>and -) marks. Not sure what versions of linker support groups though.
> >>Please find attached a trivial patch implementing grouping.
> > Hmm... ld manual says this switch can considerable slow down linking. Do
> > you observe any such effect? This solution is easier, so if it has no
> > drawbacks, we can use it instead of writing some code.
> I don't see any considerable slowdown, but then again my linking phase
> is not that long. The question is whether it slows down things comparing
> to libraries in right order, which is most likely true, or comparing to
> unordered libraries put twice on command line. Docs hint that linker
> will repeatedly scan libraries between -( and -) until all symbols are
> resolved, so it might be even faster than current solution! Suppose that
> by chance library order was correct, then -( -) way will scan them only
> once, while current approach will do it twice. Not to mention that
> current approach fails sometimes as I observe on my project.
I sure like the fact that your patch fixes real failures with a little of
> Of course it is just guessing, but what I am trying to say is that -( -)
> seems to be a pretty good quick fix, in long term it would be nice to
> actually resolve library order correctly if, in fact it will improve
> linking time.
That sounds reasonable.
> I'll try to do an experiment tonight, measure ld performance in all 3
> cases -- libraries in right order, libraries put two times on command
> line and -( -). Unfortunately my project is not too big and it might be
> hard to see the difference. Any volunteers out there to do similar thing
> on their projects?
I'd be interested to know your result. I'll also ask on binutils mailing list.
Since it's New Year holidays in Russia, I'll be back online only next Monday,
so I'll be able to apply your patch only then.
Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk