tsort lists the vertices of a
directed acyclic graph in such an order that all ordering/direction relations are respected:
Call graph tsort can help rearranging functions in a source file so that as many as possible are defined before they are used (Interpret the following as: calls , and ; calls , and so on. The result is that should be defined first, second, etc.):
Library The traditional
ld (Unix linker) requires that its library inputs be sorted in topological order, since it processes files in a single pass. This applies both to static libraries () and dynamic libraries (), and in the case of static libraries preferably for the individual object files contained within. BSD UNIX uses tsort as a common part of the typical
ar &
ranlib command invocations (from /usr/share/mk/bsd.lib.mk): lib${LIB}.a: ${OBJS} ${STATICOBJS} @${ECHO} building static ${LIB} library @${AR} cq ${.TARGET} `lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD} ${RANLIB} ${.TARGET} Here ("library order") is used to generate the inter-file dependency list by inspecting the symbol table. ==Usage notes==