Karsten Hopp c38f8e
To: vim_dev@googlegroups.com
Karsten Hopp c38f8e
Subject: Patch 7.3.050
Karsten Hopp c38f8e
Fcc: outbox
Karsten Hopp c38f8e
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp c38f8e
Mime-Version: 1.0
Karsten Hopp c38f8e
Content-Type: text/plain; charset=UTF-8
Karsten Hopp c38f8e
Content-Transfer-Encoding: 8bit
Karsten Hopp c38f8e
------------
Karsten Hopp c38f8e
Karsten Hopp c38f8e
Patch 7.3.050
Karsten Hopp c38f8e
Problem:    The link script is clumsy.
Karsten Hopp c38f8e
Solution:   Use the --as-needed linker option if available. (Kirill A.
Karsten Hopp c38f8e
	    Shutemov)
Karsten Hopp c38f8e
Files:	    src/Makefile, src/auto/configure, src/config.mk.in,
Karsten Hopp c38f8e
	    src/configure.in, src/link.sh
Karsten Hopp c38f8e
Karsten Hopp c38f8e
Karsten Hopp c38f8e
*** ../vim-7.3.049/src/Makefile	2010-10-27 16:49:41.000000000 +0200
Karsten Hopp c38f8e
--- src/Makefile	2010-11-03 22:26:45.000000000 +0100
Karsten Hopp c38f8e
***************
Karsten Hopp c38f8e
*** 1700,1706 ****
Karsten Hopp c38f8e
  	$(CCC) version.c -o objects/version.o
Karsten Hopp c38f8e
  	@LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \
Karsten Hopp c38f8e
  		-o $(VIMTARGET) $(OBJ) objects/version.o $(ALL_LIBS)" \
Karsten Hopp c38f8e
! 		MAKE="$(MAKE)" sh $(srcdir)/link.sh
Karsten Hopp c38f8e
  
Karsten Hopp c38f8e
  xxd/xxd$(EXEEXT): xxd/xxd.c
Karsten Hopp c38f8e
  	cd xxd; CC="$(CC)" CFLAGS="$(CPPFLAGS) $(CFLAGS)" \
Karsten Hopp c38f8e
--- 1700,1707 ----
Karsten Hopp c38f8e
  	$(CCC) version.c -o objects/version.o
Karsten Hopp c38f8e
  	@LINK="$(PURIFY) $(SHRPENV) $(CClink) $(ALL_LIB_DIRS) $(LDFLAGS) \
Karsten Hopp c38f8e
  		-o $(VIMTARGET) $(OBJ) objects/version.o $(ALL_LIBS)" \
Karsten Hopp c38f8e
! 		MAKE="$(MAKE)" LINK_AS_NEEDED=$(LINK_AS_NEEDED) \
Karsten Hopp c38f8e
! 		sh $(srcdir)/link.sh
Karsten Hopp c38f8e
  
Karsten Hopp c38f8e
  xxd/xxd$(EXEEXT): xxd/xxd.c
Karsten Hopp c38f8e
  	cd xxd; CC="$(CC)" CFLAGS="$(CPPFLAGS) $(CFLAGS)" \
Karsten Hopp c38f8e
*** ../vim-7.3.049/src/auto/configure	2010-11-03 21:59:23.000000000 +0100
Karsten Hopp c38f8e
--- src/auto/configure	2010-11-03 22:28:03.000000000 +0100
Karsten Hopp c38f8e
***************
Karsten Hopp c38f8e
*** 593,598 ****
Karsten Hopp c38f8e
--- 593,599 ----
Karsten Hopp c38f8e
  
Karsten Hopp c38f8e
  ac_subst_vars='LTLIBOBJS
Karsten Hopp c38f8e
  LIBOBJS
Karsten Hopp c38f8e
+ LINK_AS_NEEDED
Karsten Hopp c38f8e
  DEPEND_CFLAGS_FILTER
Karsten Hopp c38f8e
  MAKEMO
Karsten Hopp c38f8e
  MSGFMT
Karsten Hopp c38f8e
***************
Karsten Hopp c38f8e
*** 12404,12409 ****
Karsten Hopp c38f8e
--- 12405,12427 ----
Karsten Hopp c38f8e
  fi
Karsten Hopp c38f8e
  
Karsten Hopp c38f8e
  
Karsten Hopp c38f8e
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker --as-needed support" >&5
Karsten Hopp c38f8e
+ $as_echo_n "checking linker --as-needed support... " >&6; }
Karsten Hopp c38f8e
+ LINK_AS_NEEDED=
Karsten Hopp c38f8e
+ # Check if linker supports --as-needed and --no-as-needed options
Karsten Hopp c38f8e
+ if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Karsten Hopp c38f8e
+   LDFLAGS="$LDFLAGS -Wl,--as-needed"
Karsten Hopp c38f8e
+   LINK_AS_NEEDED=yes
Karsten Hopp c38f8e
+ fi
Karsten Hopp c38f8e
+ if test "$LINK_AS_NEEDED" = yes; then
Karsten Hopp c38f8e
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
Karsten Hopp c38f8e
+ $as_echo "yes" >&6; }
Karsten Hopp c38f8e
+ else
Karsten Hopp c38f8e
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
Karsten Hopp c38f8e
+ $as_echo "no" >&6; }
Karsten Hopp c38f8e
+ fi
Karsten Hopp c38f8e
+ 
Karsten Hopp c38f8e
+ 
Karsten Hopp c38f8e
  ac_config_files="$ac_config_files auto/config.mk:config.mk.in"
Karsten Hopp c38f8e
  
Karsten Hopp c38f8e
  cat >confcache <<\_ACEOF
Karsten Hopp c38f8e
*** ../vim-7.3.049/src/config.mk.in	2010-08-15 21:57:28.000000000 +0200
Karsten Hopp c38f8e
--- src/config.mk.in	2010-11-03 22:26:24.000000000 +0100
Karsten Hopp c38f8e
***************
Karsten Hopp c38f8e
*** 30,35 ****
Karsten Hopp c38f8e
--- 30,36 ----
Karsten Hopp c38f8e
  CPP		= @CPP@
Karsten Hopp c38f8e
  CPP_MM		= @CPP_MM@
Karsten Hopp c38f8e
  DEPEND_CFLAGS_FILTER = @DEPEND_CFLAGS_FILTER@
Karsten Hopp c38f8e
+ LINK_AS_NEEDED	= @LINK_AS_NEEDED@
Karsten Hopp c38f8e
  X_CFLAGS	= @X_CFLAGS@
Karsten Hopp c38f8e
  X_LIBS_DIR	= @X_LIBS@
Karsten Hopp c38f8e
  X_PRE_LIBS	= @X_PRE_LIBS@
Karsten Hopp c38f8e
*** ../vim-7.3.049/src/configure.in	2010-11-03 21:59:23.000000000 +0100
Karsten Hopp c38f8e
--- src/configure.in	2010-11-03 22:26:16.000000000 +0100
Karsten Hopp c38f8e
***************
Karsten Hopp c38f8e
*** 3527,3532 ****
Karsten Hopp c38f8e
--- 3527,3549 ----
Karsten Hopp c38f8e
  fi
Karsten Hopp c38f8e
  AC_SUBST(DEPEND_CFLAGS_FILTER)
Karsten Hopp c38f8e
  
Karsten Hopp c38f8e
+ dnl link.sh tries to avoid overlinking in a hackish way.
Karsten Hopp c38f8e
+ dnl At least GNU ld supports --as-needed which provides the same functionality
Karsten Hopp c38f8e
+ dnl at linker level. Let's use it.
Karsten Hopp c38f8e
+ AC_MSG_CHECKING(linker --as-needed support)
Karsten Hopp c38f8e
+ LINK_AS_NEEDED=
Karsten Hopp c38f8e
+ # Check if linker supports --as-needed and --no-as-needed options
Karsten Hopp c38f8e
+ if $CC -Wl,--help 2>/dev/null | grep as-needed > /dev/null; then
Karsten Hopp c38f8e
+   LDFLAGS="$LDFLAGS -Wl,--as-needed"
Karsten Hopp c38f8e
+   LINK_AS_NEEDED=yes
Karsten Hopp c38f8e
+ fi
Karsten Hopp c38f8e
+ if test "$LINK_AS_NEEDED" = yes; then
Karsten Hopp c38f8e
+   AC_MSG_RESULT(yes)
Karsten Hopp c38f8e
+ else
Karsten Hopp c38f8e
+   AC_MSG_RESULT(no)
Karsten Hopp c38f8e
+ fi
Karsten Hopp c38f8e
+ AC_SUBST(LINK_AS_NEEDED)
Karsten Hopp c38f8e
+ 
Karsten Hopp c38f8e
  dnl write output files
Karsten Hopp c38f8e
  AC_OUTPUT(auto/config.mk:config.mk.in)
Karsten Hopp c38f8e
  
Karsten Hopp c38f8e
*** ../vim-7.3.049/src/link.sh	2010-08-15 21:57:25.000000000 +0200
Karsten Hopp c38f8e
--- src/link.sh	2010-11-03 22:26:08.000000000 +0100
Karsten Hopp c38f8e
***************
Karsten Hopp c38f8e
*** 5,11 ****
Karsten Hopp c38f8e
  # libraries when they exist, but this doesn't mean they are needed for Vim.
Karsten Hopp c38f8e
  #
Karsten Hopp c38f8e
  #      Author: Bram Moolenaar
Karsten Hopp c38f8e
! # Last change: 2006 Sep 26
Karsten Hopp c38f8e
  #     License: Public domain
Karsten Hopp c38f8e
  #
Karsten Hopp c38f8e
  # Warning: This fails miserably if the linker doesn't return an error code!
Karsten Hopp c38f8e
--- 5,11 ----
Karsten Hopp c38f8e
  # libraries when they exist, but this doesn't mean they are needed for Vim.
Karsten Hopp c38f8e
  #
Karsten Hopp c38f8e
  #      Author: Bram Moolenaar
Karsten Hopp c38f8e
! # Last change: 2010 Nov 03
Karsten Hopp c38f8e
  #     License: Public domain
Karsten Hopp c38f8e
  #
Karsten Hopp c38f8e
  # Warning: This fails miserably if the linker doesn't return an error code!
Karsten Hopp c38f8e
***************
Karsten Hopp c38f8e
*** 16,26 ****
Karsten Hopp c38f8e
  echo "$LINK " >link.cmd
Karsten Hopp c38f8e
  exit_value=0
Karsten Hopp c38f8e
  
Karsten Hopp c38f8e
  #
Karsten Hopp c38f8e
  # If auto/link.sed already exists, use it.  We assume a previous run of
Karsten Hopp c38f8e
  # link.sh has found the correct set of libraries.
Karsten Hopp c38f8e
  #
Karsten Hopp c38f8e
- if test -f auto/link.sed; then
Karsten Hopp c38f8e
    echo "link.sh: The file 'auto/link.sed' exists, which is going to be used now."
Karsten Hopp c38f8e
    echo "link.sh: If linking fails, try deleting the auto/link.sed file."
Karsten Hopp c38f8e
    echo "link.sh: If this fails too, try creating an empty auto/link.sed file."
Karsten Hopp c38f8e
--- 16,38 ----
Karsten Hopp c38f8e
  echo "$LINK " >link.cmd
Karsten Hopp c38f8e
  exit_value=0
Karsten Hopp c38f8e
  
Karsten Hopp c38f8e
+ if test "$LINK_AS_NEEDED" = yes; then
Karsten Hopp c38f8e
+   echo "link.sh: \$LINK_AS_NEEDED set to 'yes': invoking linker directly."
Karsten Hopp c38f8e
+   cat link.cmd
Karsten Hopp c38f8e
+   if sh link.cmd; then
Karsten Hopp c38f8e
+     exit_value=0
Karsten Hopp c38f8e
+     echo "link.sh: Linked fine"
Karsten Hopp c38f8e
+   else
Karsten Hopp c38f8e
+     exit_value=$?
Karsten Hopp c38f8e
+     echo "link.sh: Linking failed"
Karsten Hopp c38f8e
+   fi
Karsten Hopp c38f8e
+ else
Karsten Hopp c38f8e
+   if test -f auto/link.sed; then
Karsten Hopp c38f8e
+ 
Karsten Hopp c38f8e
  #
Karsten Hopp c38f8e
  # If auto/link.sed already exists, use it.  We assume a previous run of
Karsten Hopp c38f8e
  # link.sh has found the correct set of libraries.
Karsten Hopp c38f8e
  #
Karsten Hopp c38f8e
    echo "link.sh: The file 'auto/link.sed' exists, which is going to be used now."
Karsten Hopp c38f8e
    echo "link.sh: If linking fails, try deleting the auto/link.sed file."
Karsten Hopp c38f8e
    echo "link.sh: If this fails too, try creating an empty auto/link.sed file."
Karsten Hopp c38f8e
***************
Karsten Hopp c38f8e
*** 124,129 ****
Karsten Hopp c38f8e
--- 136,143 ----
Karsten Hopp c38f8e
    fi
Karsten Hopp c38f8e
  fi
Karsten Hopp c38f8e
  
Karsten Hopp c38f8e
+ fi
Karsten Hopp c38f8e
+ 
Karsten Hopp c38f8e
  #
Karsten Hopp c38f8e
  # cleanup
Karsten Hopp c38f8e
  #
Karsten Hopp c38f8e
*** ../vim-7.3.049/src/version.c	2010-11-03 21:59:23.000000000 +0100
Karsten Hopp c38f8e
--- src/version.c	2010-11-03 22:30:17.000000000 +0100
Karsten Hopp c38f8e
***************
Karsten Hopp c38f8e
*** 716,717 ****
Karsten Hopp c38f8e
--- 716,719 ----
Karsten Hopp c38f8e
  {   /* Add new patch number below this line */
Karsten Hopp c38f8e
+ /**/
Karsten Hopp c38f8e
+     50,
Karsten Hopp c38f8e
  /**/
Karsten Hopp c38f8e
Karsten Hopp c38f8e
-- 
Karsten Hopp c38f8e
Save the plankton - eat a whale.
Karsten Hopp c38f8e
Karsten Hopp c38f8e
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp c38f8e
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp c38f8e
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp c38f8e
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///