trylink: do not drop libs from CONFIG_EXTRA_LDLIBS
No binary (build failed)
—
(log yok)
| @@ -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 | |
| @@ -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!) | |
| @@ -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 \ | |