diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-10-07 17:05:42 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-10-07 17:05:42 +0000 |
| commit | 76a6b236a9e2654e8c296c61cf71e0cf8bf4a64c (patch) | |
| tree | 289014f80d67bd02f3e2295ab9dc7d8ff02f03c6 /scripts/trylink | |
| parent | 3240474c23bf4f47536a854693b4cbacb54b9b04 (diff) | |
| download | busybox-w32-76a6b236a9e2654e8c296c61cf71e0cf8bf4a64c.tar.gz busybox-w32-76a6b236a9e2654e8c296c61cf71e0cf8bf4a64c.tar.bz2 busybox-w32-76a6b236a9e2654e8c296c61cf71e0cf8bf4a64c.zip | |
reviving libbusybox, adding CONFIG_INDIVIDUAL part 2
Diffstat (limited to 'scripts/trylink')
| -rwxr-xr-x | scripts/trylink | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/scripts/trylink b/scripts/trylink index 19b0ba715..c621b7c01 100755 --- a/scripts/trylink +++ b/scripts/trylink | |||
| @@ -21,12 +21,12 @@ A_FILES="$5" | |||
| 21 | LDLIBS="$6" | 21 | LDLIBS="$6" |
| 22 | 22 | ||
| 23 | # Sanitize lib list (dups, extra spaces etc) | 23 | # Sanitize lib list (dups, extra spaces etc) |
| 24 | BBOX_LIB_LIST=`echo "$BBOX_LIB_LIST" | xargs -n1 | sort | uniq | xargs` | 24 | LDLIBS=`echo "$LDLIBS" | xargs -n1 | sort | uniq | xargs` |
| 25 | 25 | ||
| 26 | # First link with all libs. If it fails, bail out | 26 | # First link with all libs. If it fails, bail out |
| 27 | echo "Trying libraries: $BBOX_LIB_LIST" | 27 | echo "Trying libraries: $LDLIBS" |
| 28 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" | 28 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" |
| 29 | l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` | 29 | l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` |
| 30 | test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" | 30 | test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" |
| 31 | try $CC $LDFLAGS \ | 31 | try $CC $LDFLAGS \ |
| 32 | -o $EXE -Wl,-Map -Wl,$EXE.map \ | 32 | -o $EXE -Wl,-Map -Wl,$EXE.map \ |
| @@ -42,11 +42,11 @@ try $CC $LDFLAGS \ | |||
| 42 | 42 | ||
| 43 | # Now try to remove each lib and build without it. | 43 | # Now try to remove each lib and build without it. |
| 44 | # Stop when no lib can be removed. | 44 | # Stop when no lib can be removed. |
| 45 | while test "$BBOX_LIB_LIST"; do | 45 | while test "$LDLIBS"; do |
| 46 | $debug && echo "Trying libraries: $BBOX_LIB_LIST" | 46 | $debug && echo "Trying libraries: $LDLIBS" |
| 47 | all_needed=true | 47 | all_needed=true |
| 48 | for one in $BBOX_LIB_LIST; do | 48 | for one in $LDLIBS; do |
| 49 | without_one=`echo " $BBOX_LIB_LIST " | sed "s/ $one / /g" | xargs` | 49 | without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs` |
| 50 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" | 50 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" |
| 51 | l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` | 51 | l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` |
| 52 | test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" | 52 | test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" |
| @@ -59,7 +59,7 @@ while test "$BBOX_LIB_LIST"; do | |||
| 59 | >/dev/null | 59 | >/dev/null |
| 60 | if test $? = 0; then | 60 | if test $? = 0; then |
| 61 | echo "Library $one is not needed" | 61 | echo "Library $one is not needed" |
| 62 | BBOX_LIB_LIST="$without_one" | 62 | LDLIBS="$without_one" |
| 63 | all_needed=false | 63 | all_needed=false |
| 64 | else | 64 | else |
| 65 | echo "Library $one is needed" | 65 | echo "Library $one is needed" |
| @@ -70,12 +70,12 @@ while test "$BBOX_LIB_LIST"; do | |||
| 70 | # If there is no space char, the list has just one lib. | 70 | # If there is no space char, the list has just one lib. |
| 71 | # I'm not sure that in this case lib really is 100% needed. | 71 | # I'm not sure that in this case lib really is 100% needed. |
| 72 | # Let's try linking without it anyway... thus commented out. | 72 | # Let's try linking without it anyway... thus commented out. |
| 73 | #{ echo "$BBOX_LIB_LIST" | grep -q ' '; } || break | 73 | #{ echo "$LDLIBS" | grep -q ' '; } || break |
| 74 | done | 74 | done |
| 75 | 75 | ||
| 76 | # Make the binary with final, minimal list of libs | 76 | # Make the binary with final, minimal list of libs |
| 77 | echo "Final link with: $BBOX_LIB_LIST" | 77 | echo "Final link with: $LDLIBS" |
| 78 | l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` | 78 | l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` |
| 79 | test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group -Wl,--verbose" | 79 | test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group -Wl,--verbose" |
| 80 | # --verbose gives us gobs of info to stdout (e.g. linker script used) | 80 | # --verbose gives us gobs of info to stdout (e.g. linker script used) |
| 81 | if ! test -f busybox_ldscript; then | 81 | if ! test -f busybox_ldscript; then |
| @@ -87,11 +87,11 @@ if ! test -f busybox_ldscript; then | |||
| 87 | >/dev/null | 87 | >/dev/null |
| 88 | else | 88 | else |
| 89 | echo "Custom linker script 'busybox_ldscript' found, using it" | 89 | echo "Custom linker script 'busybox_ldscript' found, using it" |
| 90 | # Add SORT_BY_ALIGNMENT to linker script (found in ${EXE}_ld.out): | 90 | # Add SORT_BY_ALIGNMENT to linker script (found in $EXE.out): |
| 91 | # .rodata : { *(.rodata SORT_BY_ALIGNMENT(.rodata.*) .gnu.linkonce.r.*) } | 91 | # .rodata : { *(.rodata SORT_BY_ALIGNMENT(.rodata.*) .gnu.linkonce.r.*) } |
| 92 | # *(.data SORT_BY_ALIGNMENT(.data.*) .gnu.linkonce.d.*) | 92 | # *(.data SORT_BY_ALIGNMENT(.data.*) .gnu.linkonce.d.*) |
| 93 | # *(.bss SORT_BY_ALIGNMENT(.bss.*) .gnu.linkonce.b.*) | 93 | # *(.bss SORT_BY_ALIGNMENT(.bss.*) .gnu.linkonce.b.*) |
| 94 | # This will eliminate most of the data padding (~3kb). | 94 | # This will eliminate most of the padding (~3kb). |
| 95 | try $CC $LDFLAGS \ | 95 | try $CC $LDFLAGS \ |
| 96 | -o $EXE -Wl,-Map -Wl,$EXE.map \ | 96 | -o $EXE -Wl,-Map -Wl,$EXE.map \ |
| 97 | -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \ | 97 | -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \ |
| @@ -118,6 +118,7 @@ try $CC $LDFLAGS \ | |||
| 118 | echo "Linking $EXE failed" | 118 | echo "Linking $EXE failed" |
| 119 | exit 1 | 119 | exit 1 |
| 120 | } | 120 | } |
| 121 | strip -s --remove-section=.note --remove-section=.comment $EXE | ||
| 121 | 122 | ||
| 122 | EXE="0lib/busybox" | 123 | EXE="0lib/busybox" |
| 123 | try $CC $LDFLAGS \ | 124 | try $CC $LDFLAGS \ |
| @@ -131,3 +132,4 @@ try $CC $LDFLAGS \ | |||
| 131 | echo "Linking $EXE failed" | 132 | echo "Linking $EXE failed" |
| 132 | exit 1 | 133 | exit 1 |
| 133 | } | 134 | } |
| 135 | strip -s --remove-section=.note --remove-section=.comment $EXE | ||
