diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-11-19 20:36:16 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-11-19 20:36:16 +0100 |
| commit | 32511da87ddaea0824801eafebd27e11409bf444 (patch) | |
| tree | 5980e45101756c9da2fce77c0d33b7dc9a3c822f /scripts | |
| parent | 4e46b98a4574aee0a77055741d460016faa11b75 (diff) | |
| download | busybox-w32-32511da87ddaea0824801eafebd27e11409bf444.tar.gz busybox-w32-32511da87ddaea0824801eafebd27e11409bf444.tar.bz2 busybox-w32-32511da87ddaea0824801eafebd27e11409bf444.zip | |
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>
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/trylink | 21 |
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. |
| 150 | while test "$LDLIBS"; do | 150 | while 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 | ||
| 184 | done | 181 | done |
| 185 | 182 | ||
| 186 | # Make the binary with final, minimal list of libs | 183 | # Make the binary with final, minimal list of libs |
