trylink: do not drop libs from CONFIG_EXTRA_LDLIBS
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
e880c9c100
commit
1f9ed02caf
1
Makefile
1
Makefile
@ -612,6 +612,7 @@ quiet_cmd_busybox__ ?= LINK $@
|
|||||||
"$(core-y)" \
|
"$(core-y)" \
|
||||||
"$(libs-y)" \
|
"$(libs-y)" \
|
||||||
"$(LDLIBS)" \
|
"$(LDLIBS)" \
|
||||||
|
"$(CONFIG_EXTRA_LDLIBS)" \
|
||||||
&& $(srctree)/scripts/generate_BUFSIZ.sh --post include/common_bufsiz.h
|
&& $(srctree)/scripts/generate_BUFSIZ.sh --post include/common_bufsiz.h
|
||||||
|
|
||||||
# Generate System.map
|
# Generate System.map
|
||||||
|
@ -209,11 +209,6 @@ LDFLAGS += $(strip $(subst ",,$(CONFIG_EXTRA_LDFLAGS)))
|
|||||||
#"))
|
#"))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq ($(CONFIG_EXTRA_LDLIBS),)
|
|
||||||
LDLIBS += $(strip $(subst ",,$(CONFIG_EXTRA_LDLIBS)))
|
|
||||||
#"))
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Busybox is a stack-fatty so make sure we increase default size
|
# Busybox is a stack-fatty so make sure we increase default size
|
||||||
# TODO: use "make stksizes" to find & fix big stack users
|
# TODO: use "make stksizes" to find & fix big stack users
|
||||||
# (we stole scripts/checkstack.pl from the kernel... thanks guys!)
|
# (we stole scripts/checkstack.pl from the kernel... thanks guys!)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
#debug=true
|
||||||
debug=false
|
debug=false
|
||||||
|
|
||||||
# Linker flags used:
|
# Linker flags used:
|
||||||
@ -77,7 +78,13 @@ CFLAGS="$3"
|
|||||||
LDFLAGS="$4"
|
LDFLAGS="$4"
|
||||||
O_FILES="$5"
|
O_FILES="$5"
|
||||||
A_FILES="$6"
|
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"
|
LDLIBS="$7"
|
||||||
|
CONFIG_EXTRA_LDLIBS="$8"
|
||||||
|
|
||||||
# The --sort-section option is not supported by older versions of ld
|
# The --sort-section option is not supported by older versions of ld
|
||||||
SORT_SECTION="-Wl,--sort-section,alignment"
|
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
|
# First link with all libs. If it fails, bail out
|
||||||
echo "Trying libraries: $LDLIBS"
|
echo "Trying libraries: $LDLIBS"
|
||||||
# "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3"
|
# "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3"
|
||||||
l_list=`echo " $LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g'`
|
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"
|
test x"$l_list" != x"" && l_list="$START_GROUP $l_list $END_GROUP"
|
||||||
try $CC $CFLAGS $LDFLAGS \
|
try $CC $CFLAGS $LDFLAGS \
|
||||||
-o $EXE \
|
-o $EXE \
|
||||||
$SORT_COMMON \
|
$SORT_COMMON \
|
||||||
@ -151,7 +158,7 @@ while test "$LDLIBS"; do
|
|||||||
for one in $LDLIBS; do
|
for one in $LDLIBS; do
|
||||||
without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs`
|
without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs`
|
||||||
# "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3"
|
# "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"
|
test x"$l_list" != x"" && l_list="$START_GROUP $l_list $END_GROUP"
|
||||||
$debug && echo "Trying -l options: '$l_list'"
|
$debug && echo "Trying -l options: '$l_list'"
|
||||||
try $CC $CFLAGS $LDFLAGS \
|
try $CC $CFLAGS $LDFLAGS \
|
||||||
@ -179,8 +186,8 @@ done
|
|||||||
|
|
||||||
# Make the binary with final, minimal list of libs
|
# Make the binary with final, minimal list of libs
|
||||||
echo "Final link with: ${LDLIBS:-<none>}"
|
echo "Final link with: ${LDLIBS:-<none>}"
|
||||||
l_list=`echo " $LDLIBS " | sed -e 's: \([^- ][^ ]*\): -l\1:g'`
|
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"
|
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)
|
# --verbose gives us gobs of info to stdout (e.g. linker script used)
|
||||||
if ! test -f busybox_ldscript; then
|
if ! test -f busybox_ldscript; then
|
||||||
try $CC $CFLAGS $LDFLAGS \
|
try $CC $CFLAGS $LDFLAGS \
|
||||||
|
Loading…
Reference in New Issue
Block a user