aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--Makefile.flags5
-rwxr-xr-xscripts/trylink17
3 files changed, 13 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 17f55dce2..ea182325d 100644
--- a/Makefile
+++ b/Makefile
@@ -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#"))
210endif 210endif
211 211
212ifneq ($(CONFIG_EXTRA_LDLIBS),)
213LDLIBS += $(strip $(subst ",,$(CONFIG_EXTRA_LDLIBS)))
214#"))
215endif
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
3debug=false 4debug=false
4 5
5# Linker flags used: 6# Linker flags used:
@@ -77,7 +78,13 @@ CFLAGS="$3"
77LDFLAGS="$4" 78LDFLAGS="$4"
78O_FILES="$5" 79O_FILES="$5"
79A_FILES="$6" 80A_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).
80LDLIBS="$7" 86LDLIBS="$7"
87CONFIG_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
83SORT_SECTION="-Wl,--sort-section,alignment" 90SORT_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
126echo "Trying libraries: $LDLIBS" 133echo "Trying libraries: $LDLIBS"
127# "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" 134# "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3"
128l_list=`echo " $LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g'` 135l_list=`echo " $LDLIBS $CONFIG_EXTRA_LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g' -e 's/^ *//'`
129test "x$l_list" != "x" && l_list="$START_GROUP $l_list $END_GROUP" 136test x"$l_list" != x"" && l_list="$START_GROUP $l_list $END_GROUP"
130try $CC $CFLAGS $LDFLAGS \ 137try $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
181echo "Final link with: ${LDLIBS:-<none>}" 188echo "Final link with: ${LDLIBS:-<none>}"
182l_list=`echo " $LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g'` 189l_list=`echo " $LDLIBS $CONFIG_EXTRA_LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g' -e 's/^ *//'`
183test "x$l_list" != "x" && l_list="$START_GROUP $l_list $END_GROUP" 190test 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)
185if ! test -f busybox_ldscript; then 192if ! test -f busybox_ldscript; then
186 try $CC $CFLAGS $LDFLAGS \ 193 try $CC $CFLAGS $LDFLAGS \