The algorithm for sorting libraries in topological order, as
previously implemented, had a few issues:
- It didn't make any sense.
- It didn't actually sort libraries in topological order.
- It hung on some inputs, e.g. "LLVMipo".
This commit replaces the old algorithm with a straightforward port
from llvm-config.cpp.
Can you add a comment before the function describing what it does, and perhaps reference the llvm-config code? It's doing a post-order traversal, which is apparently not what the linker expects.
Would a pre-order traversal save the list reversal? It's not immediately clear to me that it would.