aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/trylink21
1 files changed, 9 insertions, 12 deletions
diff --git a/scripts/trylink b/scripts/trylink
index ba2d265bc..bb6b2de2f 100755
--- a/scripts/trylink
+++ b/scripts/trylink
@@ -149,8 +149,8 @@ try $CC $CFLAGS $LDFLAGS \
149# Stop when no lib can be removed. 149# Stop when no lib can be removed.
150while test "$LDLIBS"; do 150while test "$LDLIBS"; do
151 $debug && echo "Trying libraries: $LDLIBS" 151 $debug && echo "Trying libraries: $LDLIBS"
152 all_needed=true 152 dropped_non_first_lib=false
153 last_needed=false 153 first_lib=true
154 for one in $LDLIBS; do 154 for one in $LDLIBS; do
155 without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs` 155 without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs`
156 # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" 156 # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3"
@@ -167,20 +167,17 @@ while test "$LDLIBS"; do
167 if test $? = 0; then 167 if test $? = 0; then
168 echo " Library $one is not needed, excluding it" 168 echo " Library $one is not needed, excluding it"
169 LDLIBS="$without_one" 169 LDLIBS="$without_one"
170 all_needed=false 170 $first_lib || dropped_non_first_lib=true
171 last_needed=false
172 else 171 else
173 echo " Library $one is needed, can't exclude it (yet)" 172 echo " Library $one is needed, can't exclude it (yet)"
174 last_needed=true 173 first_lib=false
175 fi 174 fi
176 done 175 done
177 # All libs were needed, can't remove any 176 # We can stop trying to drop libs if either all libs were needed,
178 $all_needed && break 177 # or we excluded only the _first_ few.
179 # Optimization: was the last tried lib needed? 178 # (else: we dropped some intermediate lib(s), maybe now we can succeed
180 if $last_needed; then 179 # in dropping some of the preceding ones)
181 # Was it the only one lib left? Don't test again then. 180 $dropped_non_first_lib || break
182 { echo "$LDLIBS" | grep -q ' '; } || break
183 fi
184done 181done
185 182
186# Make the binary with final, minimal list of libs 183# Make the binary with final, minimal list of libs