do full dependency graph using libraries too.
adds a solid .1 seconds of time when including a ridiculous number of libraries, but linking is so fast compared to compiling that it's hardly noticeable.
This commit is contained in:
parent
6b4c8671de
commit
3d637e1628
1 changed files with 83 additions and 60 deletions
135
bin/9l
135
bin/9l
|
|
@ -2,20 +2,20 @@
|
||||||
|
|
||||||
libsl=""
|
libsl=""
|
||||||
|
|
||||||
doautolib=1
|
doautolib=true
|
||||||
verbose=0
|
verbose=false
|
||||||
|
|
||||||
if [ "x$1" = "x-l" ]
|
if [ "x$1" = "x-l" ]
|
||||||
then
|
then
|
||||||
shift
|
shift
|
||||||
doautolib=0
|
doautolib=false
|
||||||
elif [ "x$1" = "x-v" ]
|
elif [ "x$1" = "x-v" ]
|
||||||
then
|
then
|
||||||
shift
|
shift
|
||||||
verbose=1
|
verbose=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $doautolib = 1 ]
|
if $doautolib
|
||||||
then
|
then
|
||||||
ofiles=""
|
ofiles=""
|
||||||
for i
|
for i
|
||||||
|
|
@ -31,76 +31,99 @@ then
|
||||||
autolibs=""
|
autolibs=""
|
||||||
if [ "x$ofiles" != "x" ]
|
if [ "x$ofiles" != "x" ]
|
||||||
then
|
then
|
||||||
autolibs=`
|
a=`
|
||||||
nm $ofiles |
|
nm $ofiles |
|
||||||
grep '__p9l_autolib_[a-zA-Z0-9+-]*$' |
|
grep '__p9l_autolib_[a-zA-Z0-9+-]*$' |
|
||||||
sed 's/.* __p9l_autolib_//' |
|
sed 's/.* __p9l_autolib_//' |
|
||||||
sort -u
|
sort -u
|
||||||
`
|
`
|
||||||
|
for i in $a
|
||||||
|
do
|
||||||
|
autolibs="$autolibs $i"
|
||||||
|
eval "need$i=true"
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
# echo "autolibs $autolibs"
|
|
||||||
|
|
||||||
libsl=""
|
# fetch dependencies out of libraries
|
||||||
special="mp draw 9pclient mux thread bio" # order matters
|
workq="$autolibs"
|
||||||
for i in $special
|
while [ "x$workq" != "x" ]
|
||||||
do
|
do
|
||||||
eval "need$i=0"
|
w="$workq"
|
||||||
|
workq=""
|
||||||
|
for i in $w
|
||||||
|
do
|
||||||
|
a=`
|
||||||
|
nm $PLAN9/lib/lib$i.a |
|
||||||
|
grep '__p9l_autolib_[a-zA-Z0-9+-]*$' |
|
||||||
|
sed 's/.*__p9l_autolib_//' |
|
||||||
|
sort -u
|
||||||
|
`
|
||||||
|
okayfn="true"
|
||||||
|
for j in $a
|
||||||
|
do
|
||||||
|
if eval "[ x\$need$j = x ]"
|
||||||
|
then
|
||||||
|
autolibs="$autolibs $j"
|
||||||
|
workq="$workq $j"
|
||||||
|
eval "need$j=true"
|
||||||
|
fi
|
||||||
|
if [ $j != $i ]
|
||||||
|
then
|
||||||
|
okayfn="$okayfn && have$j"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# echo "can$i: $okayfn"
|
||||||
|
eval "can$i() { $okayfn; }"
|
||||||
|
done
|
||||||
done
|
done
|
||||||
|
if $verbose
|
||||||
|
then
|
||||||
|
echo "autolibs $autolibs"
|
||||||
|
fi
|
||||||
|
|
||||||
for i in $autolibs
|
for i in $autolibs
|
||||||
do
|
do
|
||||||
case "$i" in
|
eval "have$i() { false; }"
|
||||||
9pclient)
|
|
||||||
need9pclient=1
|
|
||||||
needmux=1
|
|
||||||
needthread=1
|
|
||||||
;;
|
|
||||||
bio)
|
|
||||||
needbio=1
|
|
||||||
;;
|
|
||||||
draw)
|
|
||||||
needdraw=1
|
|
||||||
;;
|
|
||||||
mp)
|
|
||||||
needmp=1
|
|
||||||
;;
|
|
||||||
mux)
|
|
||||||
needmux=1
|
|
||||||
needthread=1
|
|
||||||
;;
|
|
||||||
plumb)
|
|
||||||
need9pclient=1
|
|
||||||
needmux=1
|
|
||||||
needthread=1
|
|
||||||
libsl="$libsl -lplumb"
|
|
||||||
;;
|
|
||||||
sec)
|
|
||||||
needmp=1
|
|
||||||
libsl="$libsl -lsec"
|
|
||||||
;;
|
|
||||||
thread)
|
|
||||||
needthread=1
|
|
||||||
;;
|
|
||||||
venti)
|
|
||||||
libsl="$libsl -lventi"
|
|
||||||
needthread=1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
libsl="$libsl -l$i"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
|
||||||
for i in $special
|
# now find correct order
|
||||||
|
libsl=""
|
||||||
|
while [ "x$autolibs" != x ]
|
||||||
do
|
do
|
||||||
if eval "[ \$need$i = 1 ]"
|
stillneed=""
|
||||||
|
didnothing=true
|
||||||
|
for i in $autolibs
|
||||||
|
do
|
||||||
|
if eval "can$i"
|
||||||
|
then
|
||||||
|
libsl="-l$i $libsl"
|
||||||
|
eval "have$i() { true; }"
|
||||||
|
didnothing=false
|
||||||
|
else
|
||||||
|
stillneed="$stillneed $i"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# break cycle by setting the last library on the list
|
||||||
|
# to have no dependencies
|
||||||
|
if $didnothing
|
||||||
then
|
then
|
||||||
libsl="$libsl -l$i"
|
j="xxx"
|
||||||
|
for i in $autolibs
|
||||||
|
do
|
||||||
|
j=$i
|
||||||
|
done
|
||||||
|
echo "dependency cycle: $autolibs; breaking with $j"
|
||||||
|
eval "can$j() { true; }"
|
||||||
fi
|
fi
|
||||||
|
autolibs="$stillneed"
|
||||||
done
|
done
|
||||||
|
if $verbose
|
||||||
|
then
|
||||||
|
echo "liborder $libsl"
|
||||||
|
fi
|
||||||
libsl="$libsl -l9"
|
libsl="$libsl -l9"
|
||||||
|
|
||||||
if [ $needdraw = 1 ]
|
if [ "x$needdraw" = xtrue ]
|
||||||
then
|
then
|
||||||
if [ "x$X11" = "x" ]
|
if [ "x$X11" = "x" ]
|
||||||
then
|
then
|
||||||
|
|
@ -146,7 +169,7 @@ case "$tag" in
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ $verbose = 1 ]
|
if $verbose
|
||||||
then
|
then
|
||||||
echo $ld -L$PLAN9/lib "$@" $libsl $extralibs
|
echo $ld -L$PLAN9/lib "$@" $libsl $extralibs
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue