
I have a script to find an appropriate link order, based on nm --extern-only --defined-only and --undefined-only. More accurately, the script produces input suitable for tsort. tsort writes cycles to stderr, so we could ensure that each cycle of objects is in a single library.
If I use a simple `find' command to get a list of objects rather than use the correct list of objects from the makefile, then I find 186 distinct object files mentioned on tsort's stderr, and 198 object files not mentioned on stderr. Take those numbers with a handful of salt given that I didn't use the correct set of object files, but it should give us some idea of how many files would be taken care of by putting cycles into libs.
I attach the perl script.
I think this idea is more or less orthogonal to Bryce's proposal re existing self-contained libs. Btw, I think that proposal good regardless of whether we use tsort to form libs.
pjrm.