summaryrefslogtreecommitdiff
path: root/scripts/trylink
diff options
context:
space:
mode:
authorDenys Vlasenko2021-02-23 23:09:49 +0100
committerDenys Vlasenko2021-02-23 23:09:49 +0100
commit1f9ed02caffb269e5fc6fbdf19fc9ba05a79e628 (patch)
treed846fe38e4c83d85f922b01f9e728da320ce30db /scripts/trylink
parente880c9c100028e6b0e805d4637139c67aea83748 (diff)
downloadbusybox-1f9ed02caffb269e5fc6fbdf19fc9ba05a79e628.zip
busybox-1f9ed02caffb269e5fc6fbdf19fc9ba05a79e628.tar.gz
trylink: do not drop libs from CONFIG_EXTRA_LDLIBS
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'scripts/trylink')
-rwxr-xr-xscripts/trylink17
1 files changed, 12 insertions, 5 deletions
diff --git a/scripts/trylink b/scripts/trylink
index 6b74f09..2255dee 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 \