scripts/trylink: be more clever when deciding that "lib elimination" has finished:
Before: Trying libraries: crypt m resolv Library crypt is not needed, excluding it Library m is needed, can't exclude it (yet) Library resolv is needed, can't exclude it (yet) Library m is needed, can't exclude it (yet) Library resolv is needed, can't exclude it (yet) Final link with: m resolv After: Trying libraries: crypt m resolv Library crypt is not needed, excluding it Library m is needed, can't exclude it (yet) Library resolv is needed, can't exclude it (yet) Final link with: m resolv Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
4e46b98a45
commit
32511da87d
@ -149,8 +149,8 @@ try $CC $CFLAGS $LDFLAGS \
|
|||||||
# Stop when no lib can be removed.
|
# Stop when no lib can be removed.
|
||||||
while test "$LDLIBS"; do
|
while test "$LDLIBS"; do
|
||||||
$debug && echo "Trying libraries: $LDLIBS"
|
$debug && echo "Trying libraries: $LDLIBS"
|
||||||
all_needed=true
|
dropped_non_first_lib=false
|
||||||
last_needed=false
|
first_lib=true
|
||||||
for one in $LDLIBS; do
|
for one in $LDLIBS; do
|
||||||
without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs`
|
without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs`
|
||||||
# "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3"
|
# "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3"
|
||||||
@ -167,20 +167,17 @@ while test "$LDLIBS"; do
|
|||||||
if test $? = 0; then
|
if test $? = 0; then
|
||||||
echo " Library $one is not needed, excluding it"
|
echo " Library $one is not needed, excluding it"
|
||||||
LDLIBS="$without_one"
|
LDLIBS="$without_one"
|
||||||
all_needed=false
|
$first_lib || dropped_non_first_lib=true
|
||||||
last_needed=false
|
|
||||||
else
|
else
|
||||||
echo " Library $one is needed, can't exclude it (yet)"
|
echo " Library $one is needed, can't exclude it (yet)"
|
||||||
last_needed=true
|
first_lib=false
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
# All libs were needed, can't remove any
|
# We can stop trying to drop libs if either all libs were needed,
|
||||||
$all_needed && break
|
# or we excluded only the _first_ few.
|
||||||
# Optimization: was the last tried lib needed?
|
# (else: we dropped some intermediate lib(s), maybe now we can succeed
|
||||||
if $last_needed; then
|
# in dropping some of the preceding ones)
|
||||||
# Was it the only one lib left? Don't test again then.
|
$dropped_non_first_lib || break
|
||||||
{ echo "$LDLIBS" | grep -q ' '; } || break
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Make the binary with final, minimal list of libs
|
# Make the binary with final, minimal list of libs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user