Package: ldapdns
Version: 2.06-3.4
Severity: important
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch oneiric

ldapdns fails to build with a linker that defaults to --as-needed, as
shown in this Ubuntu bug report:

  https://bugs.launchpad.net/ubuntu/+source/ldapdns/+bug/770748

This is because of incorrect link ordering: it puts libraries before the
objects that use them rather than after.  See:

  http://wiki.debian.org/ToolChain/DSOLinking#Only_link_with_needed_libraries

The following patch fixes this.

  * Fix link order to list libraries after the objects that require them.

--- ldapdns-2.06.orig/debian/patches/005-link_order.patch
+++ ldapdns-2.06/debian/patches/005-link_order.patch
@@ -0,0 +1,100 @@
+diff -ru ldapdns-2.06.orig/Makefile.defs ldapdns-2.06/Makefile.defs
+--- ldapdns-2.06.orig/Makefile.defs    2002-11-16 04:12:11.000000000 +0000
++++ ldapdns-2.06/Makefile.defs 2011-09-12 13:19:40.000000000 +0100
+@@ -4,9 +4,9 @@
+ 
+ all: ldapdns ldapaxfr
+ ldapdns: udpserver.o $(CORE)
+-      $(CC) $(CFLAGS) $(LFLAGS) -o $@ udpserver.o $(CORE)
++      $(CC) $(CFLAGS) -o $@ udpserver.o $(CORE) $(LFLAGS)
+ ldapaxfr: tcpserver.o $(CORE)
+-      $(CC) $(CFLAGS) $(LFLAGS) -o $@ tcpserver.o $(CORE)
++      $(CC) $(CFLAGS) -o $@ tcpserver.o $(CORE) $(LFLAGS)
+ 
+ error.o: error.c version.h str.h
+ udpserver.o: udpserver.c env.h config.h ldapdns.h
+diff -ru ldapdns-2.06.orig/configure ldapdns-2.06/configure
+--- ldapdns-2.06.orig/configure        2004-12-31 03:15:21.000000000 +0000
++++ ldapdns-2.06/configure     2011-09-12 13:19:13.000000000 +0100
+@@ -252,12 +252,12 @@
+ #include <pthread.h>
+ int main(int argc, char *argv[]) { pthread_create(0,0,0,0); return 0; }
+ __test_1_eof
+-if $CC $LIBS $CFLAGS -o test_1 test_1.c >/dev/null 2>&1; then
++if $CC $CFLAGS -o test_1 test_1.c $LIBS >/dev/null 2>&1; then
+       echo "ok"
+-elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lc_r >/dev/null 2>&1; then
++elif $CC $CFLAGS -o test_1 test_1.c $LIBS -lc_r >/dev/null 2>&1; then
+       echo "-lc_r"
+       LIBS="$LIBS -lc_r"
+-elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lpthread >/dev/null 2>&1; then
++elif $CC $CFLAGS -o test_1 test_1.c $LIBS -lpthread >/dev/null 2>&1; then
+       echo "-lpthread"
+       LIBS="$LIBS -lpthread"
+ else
+@@ -270,7 +270,7 @@
+ #include <pthread.h>
+ int main(int argc, char *argv[]) { pthread_kill_other_threads_np(); return 0; 
}
+ __test_1_eof
+-if $CC $LIBS $CFLAGS -o test_1 test_1.c >/dev/null 2>&1; then
++if $CC $CFLAGS -o test_1 test_1.c $LIBS >/dev/null 2>&1; then
+       echo "pthread_kill_other_threads_np"
+       CFLAGS="$CFLAGS -DHAVE_pthread_kill_other_threads_np"
+ else
+@@ -285,36 +285,36 @@
+ #include <lber.h>
+ int main(int argc, char *argv[]) { LDAP *x = ldap_open(0,0); bind(0,0,0); 
connect(0,0,0); return 0; }
+ __test_1_eof
+-if $CC $LIBS $CFLAGS -o test_1 test_1.c >/dev/null 2>&1; then
++if $CC $CFLAGS -o test_1 test_1.c $LIBS >/dev/null 2>&1; then
+       echo "ok"
+-elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lsocket >/dev/null 2>&1; then
++elif $CC $CFLAGS -o test_1 test_1.c $LIBS -lsocket >/dev/null 2>&1; then
+       echo "-lsocket"
+       LIBS="$LIBS -lsocket"
+-elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lsocket -lnsl -lssl >/dev/null 
2>&1; then
++elif $CC $CFLAGS -o test_1 test_1.c $LIBS -lsocket -lnsl -lssl >/dev/null 
2>&1; then
+       echo "-lsocket -lnsl"
+       LIBS="$LIBS -lsocket -lnsl"
+-elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lsocket -lnsl >/dev/null 2>&1; then
++elif $CC $CFLAGS -o test_1 test_1.c $LIBS -lsocket -lnsl >/dev/null 2>&1; then
+       echo "-lsocket -lnsl"
+       LIBS="$LIBS -lsocket -lnsl"
+-elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lresolv >/dev/null 2>&1; then
++elif $CC $CFLAGS -o test_1 test_1.c $LIBS -lresolv >/dev/null 2>&1; then
+       echo "-lresolv"
+       LIBS="$LIBS -lresolv"
+-elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lrt -lresolv >/dev/null 2>&1; then
++elif $CC $CFLAGS -o test_1 test_1.c $LIBS -lrt -lresolv >/dev/null 2>&1; then
+       echo "-lrt -lresolv"
+       LIBS="$LIBS -lrt -lresolv"
+-elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lrt -lresolv -lssl >/dev/null 
2>&1; then
++elif $CC $CFLAGS -o test_1 test_1.c $LIBS -lrt -lresolv -lssl >/dev/null 
2>&1; then
+       echo "-lrt -lresolv"
+       LIBS="$LIBS -lrt -lresolv"
+-elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lsocket -lresolv >/dev/null 2>&1; 
then
++elif $CC $CFLAGS -o test_1 test_1.c $LIBS -lsocket -lresolv >/dev/null 2>&1; 
then
+       echo "-lsocket -lresolv"
+       LIBS="$LIBS -lsocket -resolv"
+-elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lsocket -lnsl -lresolv >/dev/null 
2>&1; then
++elif $CC $CFLAGS -o test_1 test_1.c $LIBS -lsocket -lnsl -lresolv >/dev/null 
2>&1; then
+       echo "-lsocket -lnsl -lresolv"
+       LIBS="$LIBS -lsocket -lnsl -resolv"
+-elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lsocket -lnsl -lresolv -lssl 
>/dev/null 2>&1; then
++elif $CC $CFLAGS -o test_1 test_1.c $LIBS -lsocket -lnsl -lresolv -lssl 
>/dev/null 2>&1; then
+       echo "-lsocket -lnsl -lresolv"
+       LIBS="$LIBS -lsocket -lnsl -resolv"
+-elif $CC $LIBS $CFLAGS -o test_1 test_1.c -lcrypto -lssl -lrt -lresolv 
-lsocket -lnsl >/dev/null 2>&1; then
++elif $CC $CFLAGS -o test_1 test_1.c $LIBS -lcrypto -lssl -lrt -lresolv 
-lsocket -lnsl >/dev/null 2>&1; then
+       echo "-lcrypto -lssl -lrt -lresolv -lsocket -lnsl"
+       LIBS="$LIBS -lcrypto -lssl -lrt -lresolv -lsocket -lnsl"
+ else
+@@ -329,7 +329,7 @@
+ #include <lber.h>
+ int main(int argc, char *argv[]) { ldap_enable_cache(0, 1, 0); }
+ __test_1_eof
+-if $CC $LIBS $CFLAGS -o test_1 test_1.c >/dev/null 2>&1; then
++if $CC $CFLAGS -o test_1 test_1.c $LIBS >/dev/null 2>&1; then
+       echo "yes"
+       CFLAGS="$CFLAGS -DACCELERATE_CACHE"
+ else

-- 
Colin Watson                                       [cjwat...@ubuntu.com]



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to