diff options
| author | Dan Fandrich <dan@coneharvesters.com> | 2010-06-18 22:36:10 -0700 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-06-19 20:03:21 +0200 |
| commit | ebeac1685a6230abcf73ca36755e3bb208bfd569 (patch) | |
| tree | d93e921a421d8ee1633c27326dc045c796188c22 /scripts/trylink | |
| parent | 0635ddd8f7bbd8ed40ef4e5e01ff116ee959fa34 (diff) | |
| download | busybox-w32-ebeac1685a6230abcf73ca36755e3bb208bfd569.tar.gz busybox-w32-ebeac1685a6230abcf73ca36755e3bb208bfd569.tar.bz2 busybox-w32-ebeac1685a6230abcf73ca36755e3bb208bfd569.zip | |
Define GNU-specific link options in one place
This makes them easier to change to support a non-GNU toolchain.
Signed-off-by: Dan Fandrich <dan@coneharvesters.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'scripts/trylink')
| -rwxr-xr-x | scripts/trylink | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/scripts/trylink b/scripts/trylink index 164f5274c..021374aa9 100755 --- a/scripts/trylink +++ b/scripts/trylink | |||
| @@ -85,6 +85,11 @@ LDLIBS="$7" | |||
| 85 | # The --sort-section option is not supported by older versions of ld | 85 | # The --sort-section option is not supported by older versions of ld |
| 86 | SORT_SECTION=`check_cc "-Wl,--sort-section,alignment" ""` | 86 | SORT_SECTION=`check_cc "-Wl,--sort-section,alignment" ""` |
| 87 | 87 | ||
| 88 | START_GROUP="-Wl,--start-group" | ||
| 89 | END_GROUP="-Wl,--end-group" | ||
| 90 | |||
| 91 | INFO_OPTS="-Wl,--warn-common -Wl,-Map,$EXE.map -Wl,--verbose" | ||
| 92 | |||
| 88 | # gold may not support --sort-common (yet) | 93 | # gold may not support --sort-common (yet) |
| 89 | SORT_COMMON=`check_cc "-Wl,--sort-common" ""` | 94 | SORT_COMMON=`check_cc "-Wl,--sort-common" ""` |
| 90 | 95 | ||
| @@ -114,13 +119,13 @@ LDLIBS=`echo "$LDLIBS" | xargs -n1 | sort | uniq | xargs` | |||
| 114 | echo "Trying libraries: $LDLIBS" | 119 | echo "Trying libraries: $LDLIBS" |
| 115 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" | 120 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" |
| 116 | l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` | 121 | l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` |
| 117 | test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" | 122 | test "x$l_list" != "x" && l_list="$START_GROUP $l_list $END_GROUP" |
| 118 | try $CC $CFLAGS $LDFLAGS \ | 123 | try $CC $CFLAGS $LDFLAGS \ |
| 119 | -o $EXE \ | 124 | -o $EXE \ |
| 120 | $SORT_COMMON \ | 125 | $SORT_COMMON \ |
| 121 | $SORT_SECTION \ | 126 | $SORT_SECTION \ |
| 122 | $GC_SECTIONS \ | 127 | $GC_SECTIONS \ |
| 123 | -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ | 128 | $START_GROUP $O_FILES $A_FILES $END_GROUP \ |
| 124 | $l_list \ | 129 | $l_list \ |
| 125 | || { | 130 | || { |
| 126 | echo "Failed: $l_list" | 131 | echo "Failed: $l_list" |
| @@ -138,14 +143,14 @@ while test "$LDLIBS"; do | |||
| 138 | without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs` | 143 | without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs` |
| 139 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" | 144 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" |
| 140 | l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` | 145 | l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` |
| 141 | test x"$l_list" != x"" && l_list="-Wl,--start-group $l_list -Wl,--end-group" | 146 | test x"$l_list" != x"" && l_list="$START_GROUP $l_list $END_GROUP" |
| 142 | $debug && echo "Trying -l options: '$l_list'" | 147 | $debug && echo "Trying -l options: '$l_list'" |
| 143 | try $CC $CFLAGS $LDFLAGS \ | 148 | try $CC $CFLAGS $LDFLAGS \ |
| 144 | -o $EXE \ | 149 | -o $EXE \ |
| 145 | $SORT_COMMON \ | 150 | $SORT_COMMON \ |
| 146 | $SORT_SECTION \ | 151 | $SORT_SECTION \ |
| 147 | $GC_SECTIONS \ | 152 | $GC_SECTIONS \ |
| 148 | -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ | 153 | $START_GROUP $O_FILES $A_FILES $END_GROUP \ |
| 149 | $l_list | 154 | $l_list |
| 150 | if test $? = 0; then | 155 | if test $? = 0; then |
| 151 | echo " Library $one is not needed, excluding it" | 156 | echo " Library $one is not needed, excluding it" |
| @@ -169,7 +174,7 @@ done | |||
| 169 | # Make the binary with final, minimal list of libs | 174 | # Make the binary with final, minimal list of libs |
| 170 | echo "Final link with: ${LDLIBS:-<none>}" | 175 | echo "Final link with: ${LDLIBS:-<none>}" |
| 171 | l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` | 176 | l_list=`echo "$LDLIBS" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` |
| 172 | test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" | 177 | test "x$l_list" != "x" && l_list="$START_GROUP $l_list $END_GROUP" |
| 173 | # --verbose gives us gobs of info to stdout (e.g. linker script used) | 178 | # --verbose gives us gobs of info to stdout (e.g. linker script used) |
| 174 | if ! test -f busybox_ldscript; then | 179 | if ! test -f busybox_ldscript; then |
| 175 | try $CC $CFLAGS $LDFLAGS \ | 180 | try $CC $CFLAGS $LDFLAGS \ |
| @@ -177,11 +182,9 @@ if ! test -f busybox_ldscript; then | |||
| 177 | $SORT_COMMON \ | 182 | $SORT_COMMON \ |
| 178 | $SORT_SECTION \ | 183 | $SORT_SECTION \ |
| 179 | $GC_SECTIONS \ | 184 | $GC_SECTIONS \ |
| 180 | -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ | 185 | $START_GROUP $O_FILES $A_FILES $END_GROUP \ |
| 181 | $l_list \ | 186 | $l_list \ |
| 182 | -Wl,--warn-common \ | 187 | $INFO_OPTS \ |
| 183 | -Wl,-Map,$EXE.map \ | ||
| 184 | -Wl,--verbose \ | ||
| 185 | || { | 188 | || { |
| 186 | cat $EXE.out | 189 | cat $EXE.out |
| 187 | exit 1 | 190 | exit 1 |
| @@ -200,11 +203,9 @@ else | |||
| 200 | $SORT_SECTION \ | 203 | $SORT_SECTION \ |
| 201 | $GC_SECTIONS \ | 204 | $GC_SECTIONS \ |
| 202 | -Wl,-T,busybox_ldscript \ | 205 | -Wl,-T,busybox_ldscript \ |
| 203 | -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ | 206 | $START_GROUP $O_FILES $A_FILES $END_GROUP \ |
| 204 | $l_list \ | 207 | $l_list \ |
| 205 | -Wl,--warn-common \ | 208 | $INFO_OPTS \ |
| 206 | -Wl,-Map,$EXE.map \ | ||
| 207 | -Wl,--verbose \ | ||
| 208 | || { | 209 | || { |
| 209 | cat $EXE.out | 210 | cat $EXE.out |
| 210 | exit 1 | 211 | exit 1 |
| @@ -233,11 +234,9 @@ if test "$CONFIG_BUILD_LIBBUSYBOX" = y; then | |||
| 233 | -Wl,--undefined=lbb_main \ | 234 | -Wl,--undefined=lbb_main \ |
| 234 | $SORT_COMMON \ | 235 | $SORT_COMMON \ |
| 235 | $SORT_SECTION \ | 236 | $SORT_SECTION \ |
| 236 | -Wl,--start-group $A_FILES -Wl,--end-group \ | 237 | $START_GROUP $A_FILES $END_GROUP \ |
| 237 | $l_list \ | 238 | $l_list \ |
| 238 | -Wl,--warn-common \ | 239 | $INFO_OPTS \ |
| 239 | -Wl,-Map,$EXE.map \ | ||
| 240 | -Wl,--verbose \ | ||
| 241 | || { | 240 | || { |
| 242 | echo "Linking $EXE failed" | 241 | echo "Linking $EXE failed" |
| 243 | cat $EXE.out | 242 | cat $EXE.out |
| @@ -255,11 +254,9 @@ if test "$CONFIG_FEATURE_SHARED_BUSYBOX" = y; then | |||
| 255 | $SORT_COMMON \ | 254 | $SORT_COMMON \ |
| 256 | $SORT_SECTION \ | 255 | $SORT_SECTION \ |
| 257 | $GC_SECTIONS \ | 256 | $GC_SECTIONS \ |
| 258 | -Wl,--start-group $O_FILES -Wl,--end-group \ | 257 | $START_GROUP $O_FILES $END_GROUP \ |
| 259 | -L"$sharedlib_dir" -lbusybox \ | 258 | -L"$sharedlib_dir" -lbusybox \ |
| 260 | -Wl,--warn-common \ | 259 | $INFO_OPTS \ |
| 261 | -Wl,-Map,$EXE.map \ | ||
| 262 | -Wl,--verbose \ | ||
| 263 | || { | 260 | || { |
| 264 | echo "Linking $EXE failed" | 261 | echo "Linking $EXE failed" |
| 265 | cat $EXE.out | 262 | cat $EXE.out |
