From: Kirill Lapshin (klapshin_at_[hidden])
Date: 2003-12-29 09:25:42
> I think it's what's requested by
Sure it is.
> The problem can be split in two parts: finding order dependencies, and
> reordering the libraries. The first one can be accomplished by assuming that
> if you have
> lib a : a.cpp other_lib : <use>yet_another_lib ;
> Then 'a' should be present on the command line before 'other_lib' and
> 'yet_another_lib'. And current V2 records all those libraries. I think this
> should be enough.
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.
> The second part requires writing an algorithm for ordering but it should not
> be too hard.
>>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.
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
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?
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