[comp.os.minix] A method to order library

dlawyer@balboa.eng.uci.edu (David Lawyer) (01/17/89)

The problem of library order (/usr/lib/libc.a) has not been solved.  If
one is converting via diffs to version 1.3 then the tools needed to
order the library: lorder, tsort etc. are not available.  The method I
used was to create a library based on the old order by using the "run"
shell script found in the lib source directory.  Then when you get a
complaint from the compiler (actually linker) about a missing library
procedure, just append it to the end of libc.a (using the ar command) 
even if it is already in the library.  You will wind up with several
duplicates in the library but everything may be compiled.

AST posted his ordering in Nov. 1988 but many procedures which I got
from bugs.nosc (and from the net) are missing from it.  Some of these
are needed to compile new programs being posted to the net.  Also, some
of the postings to the net are new library routines which must be added
to libc.a.  Thus one needs to use lorder, tsort, and ar to order libc.a
but they doesn't work right because "argument list too long".

I was able to work around this problem by doing the following:  I put
all my .s library files in a separate directory.  There are about 200
of them and make sure they are all compressed assembly code.  Giving:
"lorder *.s > tmp" or the like silently hangs but "lorder LIB >tmp"
will work where LIB is a library archive containing all the .s files.
Creating LIB can't be done in one command due to the "argument list too
long" message from the shell.  But one may: "ar q LIB [_-k]*s" to make
a partial LIB and then do it again to get the j-z files (note one file
is _dup.s).  Next do: "tsort tmp >order".  This should result in an
error message that a cycle exist so remove the line "catchsig.s
signal.s" from tmp to fix this and do tsort again.

The order file now contains the order as a very long line --too long
for ar.  One way to make the libc.a from this is to use a do loop (at
the command line) to add one procedure at a time to libc.a: "for i in
`cat order` ... ".

Be sure that tsort, lorder and ar have enough stack space.  I used
chmem to get 30K for lorder, 15K for tsort and the maximum for ar.

There should be an easier way than the above to order the library.  The
shell should be made to accept longer strings as arguments.  I
increased MAX_ISTACK_BYTES to 4096 (in h/const.h) and then recompiled
exec.c, the shell etc.  No luck!  The commands still hung.