aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-02-23 23:09:49 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2021-02-23 23:09:49 +0100
commit1f9ed02caffb269e5fc6fbdf19fc9ba05a79e628 (patch)
treed846fe38e4c83d85f922b01f9e728da320ce30db
parente880c9c100028e6b0e805d4637139c67aea83748 (diff)
downloadbusybox-1f9ed02caffb269e5fc6fbdf19fc9ba05a79e628.tar.gz
trylink: do not drop libs from CONFIG_EXTRA_LDLIBS
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-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 $@
"$(core-y)" \
"$(libs-y)" \
"$(LDLIBS)" \
+ "$(CONFIG_EXTRA_LDLIBS)" \
&& $(srctree)/scripts/generate_BUFSIZ.sh --post include/common_bufsiz.h
# 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)))
#"))
endif
-ifneq ($(CONFIG_EXTRA_LDLIBS),)
-LDLIBS += $(strip $(subst ",,$(CONFIG_EXTRA_LDLIBS)))
-#"))
-endif
-
# Busybox is a stack-fatty so make sure we increase default size
# TODO: use "make stksizes" to find & fix big stack users
# (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 @@
#!/bin/sh
+#debug=true
debug=false
# Linker flags used:
@@ -77,7 +78,13 @@ CFLAGS="$3"
LDFLAGS="$4"
O_FILES="$5"
A_FILES="$6"
+# We try to drop libraries from LDLIBS if build works without them,
+# but ones from CONFIG_EXTRA_LDLIBS are always linked in.
+# (For example, musl has stub utmp implementation, and if you link with
+# a real utmp library in LDLIBS, dropping it "works" but resulting binary
+# does not work properly).
LDLIBS="$7"
+CONFIG_EXTRA_LDLIBS="$8"
# The --sort-section option is not supported by older versions of ld
SORT_SECTION="-Wl,--sort-section,alignment"
@@ -125,8 +132,8 @@ LDLIBS=`echo "$LDLIBS" | xargs -n1 | sort | uniq | xargs`
# First link with all libs. If it fails, bail out
echo "Trying libraries: $LDLIBS"
# "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3"
-l_list=`echo " $LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g'`
-test "x$l_list" != "x" && l_list="$START_GROUP $l_list $END_GROUP"
+l_list=`echo " $LDLIBS $CONFIG_EXTRA_LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g' -e 's/^ *//'`
+test x"$l_list" != x"" && l_list="$START_GROUP $l_list $END_GROUP"
try $CC $CFLAGS $LDFLAGS \
-o $EXE \
$SORT_COMMON \
@@ -151,7 +158,7 @@ while test "$LDLIBS"; do
for one in $LDLIBS; do
without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs`
# "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3"
- l_list=`echo " $without_one " | sed -e 's: \([^- ][^ ]*\): -l\1:g'`
+ l_list=`echo " $without_one $CONFIG_EXTRA_LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g' -e 's/^ *//'`
test x"$l_list" != x"" && l_list="$START_GROUP $l_list $END_GROUP"
$debug && echo "Trying -l options: '$l_list'"
try $CC $CFLAGS $LDFLAGS \
@@ -179,8 +186,8 @@ done
# Make the binary with final, minimal list of libs
echo "Final link with: ${LDLIBS:-<none>}"
-l_list=`echo " $LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g'`
-test "x$l_list" != "x" && l_list="$START_GROUP $l_list $END_GROUP"
+l_list=`echo " $LDLIBS $CONFIG_EXTRA_LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g' -e 's/^ *//'`
+test x"$l_list" != x"" && l_list="$START_GROUP $l_list $END_GROUP"
# --verbose gives us gobs of info to stdout (e.g. linker script used)
if ! test -f busybox_ldscript; then
try $CC $CFLAGS $LDFLAGS \