diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/trylink | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/scripts/trylink b/scripts/trylink index 7fe262baa..4fea6fe76 100755 --- a/scripts/trylink +++ b/scripts/trylink | |||
@@ -46,6 +46,14 @@ try() { | |||
46 | return $exitcode | 46 | return $exitcode |
47 | } | 47 | } |
48 | 48 | ||
49 | check_cc() { | ||
50 | if $CC $1 -shared -o /dev/null -xc /dev/null > /dev/null 2>&1; then | ||
51 | echo "$1"; | ||
52 | else | ||
53 | echo "$2"; | ||
54 | fi | ||
55 | } | ||
56 | |||
49 | EXE="$1" | 57 | EXE="$1" |
50 | CC="$2" | 58 | CC="$2" |
51 | LDFLAGS="$3" | 59 | LDFLAGS="$3" |
@@ -53,6 +61,9 @@ O_FILES="$4" | |||
53 | A_FILES="$5" | 61 | A_FILES="$5" |
54 | LDLIBS="$6" | 62 | LDLIBS="$6" |
55 | 63 | ||
64 | # The -Wl,--sort-section option is not supported by older versions of ld | ||
65 | SORT_SECTION=`check_cc "-Wl,--sort-section -Wl,alignment" ""` | ||
66 | |||
56 | # Sanitize lib list (dups, extra spaces etc) | 67 | # Sanitize lib list (dups, extra spaces etc) |
57 | LDLIBS=`echo "$LDLIBS" | xargs -n1 | sort | uniq | xargs` | 68 | LDLIBS=`echo "$LDLIBS" | xargs -n1 | sort | uniq | xargs` |
58 | 69 | ||
@@ -64,7 +75,7 @@ test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" | |||
64 | try $CC $LDFLAGS \ | 75 | try $CC $LDFLAGS \ |
65 | -o $EXE \ | 76 | -o $EXE \ |
66 | -Wl,--sort-common \ | 77 | -Wl,--sort-common \ |
67 | -Wl,--sort-section -Wl,alignment \ | 78 | $SORT_SECTION \ |
68 | -Wl,--gc-sections \ | 79 | -Wl,--gc-sections \ |
69 | -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ | 80 | -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ |
70 | $l_list \ | 81 | $l_list \ |
@@ -88,7 +99,7 @@ while test "$LDLIBS"; do | |||
88 | try $CC $LDFLAGS \ | 99 | try $CC $LDFLAGS \ |
89 | -o $EXE \ | 100 | -o $EXE \ |
90 | -Wl,--sort-common \ | 101 | -Wl,--sort-common \ |
91 | -Wl,--sort-section -Wl,alignment \ | 102 | $SORT_SECTION \ |
92 | -Wl,--gc-sections \ | 103 | -Wl,--gc-sections \ |
93 | -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ | 104 | -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ |
94 | $l_list | 105 | $l_list |
@@ -117,7 +128,7 @@ if ! test -f busybox_ldscript; then | |||
117 | try $CC $LDFLAGS \ | 128 | try $CC $LDFLAGS \ |
118 | -o $EXE \ | 129 | -o $EXE \ |
119 | -Wl,--sort-common \ | 130 | -Wl,--sort-common \ |
120 | -Wl,--sort-section -Wl,alignment \ | 131 | $SORT_SECTION \ |
121 | -Wl,--gc-sections \ | 132 | -Wl,--gc-sections \ |
122 | -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ | 133 | -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ |
123 | $l_list \ | 134 | $l_list \ |
@@ -139,7 +150,7 @@ else | |||
139 | try $CC $LDFLAGS \ | 150 | try $CC $LDFLAGS \ |
140 | -o $EXE \ | 151 | -o $EXE \ |
141 | -Wl,--sort-common \ | 152 | -Wl,--sort-common \ |
142 | -Wl,--sort-section -Wl,alignment \ | 153 | $SORT_SECTION \ |
143 | -Wl,--gc-sections \ | 154 | -Wl,--gc-sections \ |
144 | -Wl,-T -Wl,busybox_ldscript \ | 155 | -Wl,-T -Wl,busybox_ldscript \ |
145 | -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ | 156 | -Wl,--start-group $O_FILES $A_FILES -Wl,--end-group \ |
@@ -174,7 +185,7 @@ if test "$CONFIG_BUILD_LIBBUSYBOX" = y; then | |||
174 | -Wl,-soname="libbusybox.so.$BB_VER" \ | 185 | -Wl,-soname="libbusybox.so.$BB_VER" \ |
175 | -Wl,--undefined=lbb_main \ | 186 | -Wl,--undefined=lbb_main \ |
176 | -Wl,--sort-common \ | 187 | -Wl,--sort-common \ |
177 | -Wl,--sort-section -Wl,alignment \ | 188 | $SORT_SECTION \ |
178 | -Wl,--start-group $A_FILES -Wl,--end-group \ | 189 | -Wl,--start-group $A_FILES -Wl,--end-group \ |
179 | $l_list \ | 190 | $l_list \ |
180 | -Wl,--warn-common \ | 191 | -Wl,--warn-common \ |
@@ -195,7 +206,7 @@ if test "$CONFIG_FEATURE_SHARED_BUSYBOX" = y; then | |||
195 | try $CC $LDFLAGS \ | 206 | try $CC $LDFLAGS \ |
196 | -o $EXE \ | 207 | -o $EXE \ |
197 | -Wl,--sort-common \ | 208 | -Wl,--sort-common \ |
198 | -Wl,--sort-section -Wl,alignment \ | 209 | $SORT_SECTION \ |
199 | -Wl,--gc-sections \ | 210 | -Wl,--gc-sections \ |
200 | -Wl,--start-group $O_FILES -Wl,--end-group \ | 211 | -Wl,--start-group $O_FILES -Wl,--end-group \ |
201 | -L"$sharedlib_dir" -lbusybox \ | 212 | -L"$sharedlib_dir" -lbusybox \ |
@@ -234,7 +245,7 @@ int main(int argc, char **argv) | |||
234 | try $CC $LDFLAGS "$sharedlib_dir/applet.c" \ | 245 | try $CC $LDFLAGS "$sharedlib_dir/applet.c" \ |
235 | -o $EXE \ | 246 | -o $EXE \ |
236 | -Wl,--sort-common \ | 247 | -Wl,--sort-common \ |
237 | -Wl,--sort-section -Wl,alignment \ | 248 | $SORT_SECTION \ |
238 | -Wl,--gc-sections \ | 249 | -Wl,--gc-sections \ |
239 | -L"$sharedlib_dir" -lbusybox \ | 250 | -L"$sharedlib_dir" -lbusybox \ |
240 | -Wl,--warn-common \ | 251 | -Wl,--warn-common \ |