Sharpmake icon indicating copy to clipboard operation
Sharpmake copied to clipboard

Sort libraries first by dependency, then apply user set dependency order

Open kudaba opened this issue 3 years ago • 3 comments

Updated version of #86 which got closed when I renamed the branch. This new version is updated to also sort dependent library includes to the whole graph is in order.

The alternative to this would be just dropping /Wl,start-group/end-group around all libraries which works but might add link cost since it iterates over the whole set over and over until all symbols are satisfied (success) or no more symbols can be found (error).

kudaba avatar Feb 08 '22 07:02 kudaba

Would be great if you could add unit-tests for this :)

belkiss avatar Feb 10 '22 21:02 belkiss

Unit tests did expose a weakness in how I generate the order, so that's good, but it also shows that I'm overriding an order value of shared objects which means if I don't want it to effectively be a global setting then I'd need to have some way to generate the auto order during link and reset it after. I'll have to tinker more with it.

The start/end group option is looking pretty nice right about now. I really have no idea what the perf cost of doing it that was is though, I'm more trying to do the auto ordering to keep with the principle of only cost what's absolutely necessary.

kudaba avatar Feb 11 '22 07:02 kudaba

After some testing I realized there wasn't a good way to make this an option, unless it's a global toggle which would be easy to add if you want. I don't think there should be any harm in applying this all the time though since it should be a net benefit unless people were not declaring dependencies and relying on target order to fix linux builds anyway.

kudaba avatar Feb 20 '22 06:02 kudaba