diff options
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | Makefile.flags | 5 | ||||
-rwxr-xr-x | scripts/trylink | 17 |
3 files changed, 13 insertions, 10 deletions
@@ -612,6 +612,7 @@ quiet_cmd_busybox__ ?= LINK $@ | |||
612 | "$(core-y)" \ | 612 | "$(core-y)" \ |
613 | "$(libs-y)" \ | 613 | "$(libs-y)" \ |
614 | "$(LDLIBS)" \ | 614 | "$(LDLIBS)" \ |
615 | "$(CONFIG_EXTRA_LDLIBS)" \ | ||
615 | && $(srctree)/scripts/generate_BUFSIZ.sh --post include/common_bufsiz.h | 616 | && $(srctree)/scripts/generate_BUFSIZ.sh --post include/common_bufsiz.h |
616 | 617 | ||
617 | # Generate System.map | 618 | # Generate System.map |
diff --git a/Makefile.flags b/Makefile.flags index 7a445c3b5..3b02bfaac 100644 --- a/Makefile.flags +++ b/Makefile.flags | |||
@@ -209,11 +209,6 @@ LDFLAGS += $(strip $(subst ",,$(CONFIG_EXTRA_LDFLAGS))) | |||
209 | #")) | 209 | #")) |
210 | endif | 210 | endif |
211 | 211 | ||
212 | ifneq ($(CONFIG_EXTRA_LDLIBS),) | ||
213 | LDLIBS += $(strip $(subst ",,$(CONFIG_EXTRA_LDLIBS))) | ||
214 | #")) | ||
215 | endif | ||
216 | |||
217 | # Busybox is a stack-fatty so make sure we increase default size | 212 | # Busybox is a stack-fatty so make sure we increase default size |
218 | # TODO: use "make stksizes" to find & fix big stack users | 213 | # TODO: use "make stksizes" to find & fix big stack users |
219 | # (we stole scripts/checkstack.pl from the kernel... thanks guys!) | 214 | # (we stole scripts/checkstack.pl from the kernel... thanks guys!) |
diff --git a/scripts/trylink b/scripts/trylink index 6b74f092d..2255deee7 100755 --- a/scripts/trylink +++ b/scripts/trylink | |||
@@ -1,5 +1,6 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | #debug=true | ||
3 | debug=false | 4 | debug=false |
4 | 5 | ||
5 | # Linker flags used: | 6 | # Linker flags used: |
@@ -77,7 +78,13 @@ CFLAGS="$3" | |||
77 | LDFLAGS="$4" | 78 | LDFLAGS="$4" |
78 | O_FILES="$5" | 79 | O_FILES="$5" |
79 | A_FILES="$6" | 80 | A_FILES="$6" |
81 | # We try to drop libraries from LDLIBS if build works without them, | ||
82 | # but ones from CONFIG_EXTRA_LDLIBS are always linked in. | ||
83 | # (For example, musl has stub utmp implementation, and if you link with | ||
84 | # a real utmp library in LDLIBS, dropping it "works" but resulting binary | ||
85 | # does not work properly). | ||
80 | LDLIBS="$7" | 86 | LDLIBS="$7" |
87 | CONFIG_EXTRA_LDLIBS="$8" | ||
81 | 88 | ||
82 | # The --sort-section option is not supported by older versions of ld | 89 | # The --sort-section option is not supported by older versions of ld |
83 | SORT_SECTION="-Wl,--sort-section,alignment" | 90 | SORT_SECTION="-Wl,--sort-section,alignment" |
@@ -125,8 +132,8 @@ LDLIBS=`echo "$LDLIBS" | xargs -n1 | sort | uniq | xargs` | |||
125 | # First link with all libs. If it fails, bail out | 132 | # First link with all libs. If it fails, bail out |
126 | echo "Trying libraries: $LDLIBS" | 133 | echo "Trying libraries: $LDLIBS" |
127 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" | 134 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" |
128 | l_list=`echo " $LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g'` | 135 | l_list=`echo " $LDLIBS $CONFIG_EXTRA_LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g' -e 's/^ *//'` |
129 | test "x$l_list" != "x" && l_list="$START_GROUP $l_list $END_GROUP" | 136 | test x"$l_list" != x"" && l_list="$START_GROUP $l_list $END_GROUP" |
130 | try $CC $CFLAGS $LDFLAGS \ | 137 | try $CC $CFLAGS $LDFLAGS \ |
131 | -o $EXE \ | 138 | -o $EXE \ |
132 | $SORT_COMMON \ | 139 | $SORT_COMMON \ |
@@ -151,7 +158,7 @@ while test "$LDLIBS"; do | |||
151 | for one in $LDLIBS; do | 158 | for one in $LDLIBS; do |
152 | without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs` | 159 | without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs` |
153 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" | 160 | # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" |
154 | l_list=`echo " $without_one " | sed -e 's: \([^- ][^ ]*\): -l\1:g'` | 161 | l_list=`echo " $without_one $CONFIG_EXTRA_LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g' -e 's/^ *//'` |
155 | test x"$l_list" != x"" && l_list="$START_GROUP $l_list $END_GROUP" | 162 | test x"$l_list" != x"" && l_list="$START_GROUP $l_list $END_GROUP" |
156 | $debug && echo "Trying -l options: '$l_list'" | 163 | $debug && echo "Trying -l options: '$l_list'" |
157 | try $CC $CFLAGS $LDFLAGS \ | 164 | try $CC $CFLAGS $LDFLAGS \ |
@@ -179,8 +186,8 @@ done | |||
179 | 186 | ||
180 | # Make the binary with final, minimal list of libs | 187 | # Make the binary with final, minimal list of libs |
181 | echo "Final link with: ${LDLIBS:-<none>}" | 188 | echo "Final link with: ${LDLIBS:-<none>}" |
182 | l_list=`echo " $LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g'` | 189 | l_list=`echo " $LDLIBS $CONFIG_EXTRA_LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g' -e 's/^ *//'` |
183 | test "x$l_list" != "x" && l_list="$START_GROUP $l_list $END_GROUP" | 190 | test x"$l_list" != x"" && l_list="$START_GROUP $l_list $END_GROUP" |
184 | # --verbose gives us gobs of info to stdout (e.g. linker script used) | 191 | # --verbose gives us gobs of info to stdout (e.g. linker script used) |
185 | if ! test -f busybox_ldscript; then | 192 | if ! test -f busybox_ldscript; then |
186 | try $CC $CFLAGS $LDFLAGS \ | 193 | try $CC $CFLAGS $LDFLAGS \ |