link.sh tries to avoid overlinking in a hackish way. At least GNU ld supports --as-needed which provides the same functionality at linker level. Let's use it.
Signed-off-by: Kirill A. Shutemov <[email protected]> --- src/Makefile | 2 +- src/config.mk.in | 1 + src/configure.in | 17 +++++++++++++++++ src/link.sh | 6 +++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index 5c0729f..0156084 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1688,7 +1688,7 @@ $(VIMTARGET): auto/config.mk objects $(OBJ) version.c version.h $(CCC) version.c -o objects/version.o @LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \ -o $(VIMTARGET) $(OBJ) objects/version.o $(ALL_LIBS)" \ - MAKE="$(MAKE)" sh $(srcdir)/link.sh + MAKE="$(MAKE)" NO_LINK_SH=$(NO_LINK_SH) sh $(srcdir)/link.sh xxd/xxd$(EXEEXT): xxd/xxd.c cd xxd; CC="$(CC)" CFLAGS="$(CPPFLAGS) $(CFLAGS)" \ diff --git a/src/config.mk.in b/src/config.mk.in index 7154114..cd334c6 100644 --- a/src/config.mk.in +++ b/src/config.mk.in @@ -30,6 +30,7 @@ TAGPRG = @TAGPRG@ CPP = @CPP@ CPP_MM = @CPP_MM@ DEPEND_CFLAGS_FILTER = @DEPEND_CFLAGS_FILTER@ +NO_LINK_SH = @NO_LINK_SH@ X_CFLAGS = @X_CFLAGS@ X_LIBS_DIR = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ diff --git a/src/configure.in b/src/configure.in index 3b9f812..a4e5e74 100644 --- a/src/configure.in +++ b/src/configure.in @@ -3479,6 +3479,23 @@ else fi AC_SUBST(DEPEND_CFLAGS_FILTER) +dnl link.sh tries to avoid overlinking in a hackish way. +dnl At least GNU ld supports --as-needed which provides the same functionality +dnl at linker level. Let's use it. +AC_MSG_CHECKING(linker --as-needed support) +NO_LINK_SH= +# Check if linker supports --as-needed and --no-as-needed options +if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then + LDFLAGS="$LDFLAGS -Wl,--as-needed" + NO_LINK_SH=yes +fi +if test "$NO_LINK_SH" = yes; then + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi +AC_SUBST(NO_LINK_SH) + dnl write output files AC_OUTPUT(auto/config.mk:config.mk.in) diff --git a/src/link.sh b/src/link.sh index 3d90f3c..06632dc 100755 --- a/src/link.sh +++ b/src/link.sh @@ -16,11 +16,15 @@ echo "$LINK " >link.cmd exit_value=0 +if test "$NO_LINK_SH" = yes; then + echo "link.sh: \$NO_LINK_SH set to 'yes': no needed in reducing library set." + echo > auto/link.sed +elif test -f auto/link.sed; then + # # If auto/link.sed already exists, use it. We assume a previous run of # link.sh has found the correct set of libraries. # -if test -f auto/link.sed; then echo "link.sh: The file 'auto/link.sed' exists, which is going to be used now." echo "link.sh: If linking fails, try deleting the auto/link.sed file." echo "link.sh: If this fails too, try creating an empty auto/link.sed file." -- Kirill A. Shutemov -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
