[pacman-dev] [PATCH] Add "-Wl,--as-needed" to libalpm LDFLAGS.

Lukas Fleischer archlinux at cryptocrack.de
Sat Mar 19 16:28:34 EDT 2011


Also includes a Debian patch (from #347650) that makes libtool play
nicely with "-Wl,--as-needed".

Signed-off-by: Lukas Fleischer <archlinux at cryptocrack.de>
---
 lib/libalpm/Makefile.am |    2 +-
 ltmain.sh               |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/lib/libalpm/Makefile.am b/lib/libalpm/Makefile.am
index 1bda571..4c329b8 100644
--- a/lib/libalpm/Makefile.am
+++ b/lib/libalpm/Makefile.am
@@ -52,7 +52,7 @@ libalpm_la_SOURCES += \
 	md5.h md5.c
 endif
 
-libalpm_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_INFO)
+libalpm_la_LDFLAGS = -no-undefined -version-info $(LIB_VERSION_INFO) -Wl,--as-needed
 libalpm_la_LIBADD = $(LTLIBINTL)
 
 # vim:set ts=2 sw=2 noet:
diff --git a/ltmain.sh b/ltmain.sh
index 6c02b18..4e98c79 100755
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -5790,6 +5790,11 @@ func_mode_link ()
 	arg=$func_stripname_result
 	;;
 
+      -Wl,--as-needed|-Wl,--no-as-needed)
+	deplibs="$deplibs $arg"
+	continue
+	;;
+
       -Wl,*)
 	func_stripname '-Wl,' '' "$arg"
 	args=$func_stripname_result
@@ -6150,6 +6155,15 @@ func_mode_link ()
 	lib=
 	found=no
 	case $deplib in
+	-Wl,--as-needed|-Wl,--no-as-needed)
+	  if test "$linkmode,$pass" = "prog,link"; then
+	    compile_deplibs="$deplib $compile_deplibs"
+	    finalize_deplibs="$deplib $finalize_deplibs"
+	  else
+	    deplibs="$deplib $deplibs"
+	  fi
+	  continue
+	  ;;
 	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
 	  if test "$linkmode,$pass" = "prog,link"; then
 	    compile_deplibs="$deplib $compile_deplibs"
-- 
1.7.4.1



More information about the pacman-dev mailing list