Package: isakmpd
Version: 20041012-7.2
Severity: normal
Tags: upstream patch
User: [email protected]
Usertags: ld-as-needed

isakmpd fails to build when --as-needed linker option is enabled,
because of incorrect order of parameters passed to ld.

make[2]: Entering directory `/tmp/buildd/isakmpd-20041012/apps/certpatch'
cc -I../.. -I../../sysdep/linux -I -Wall -DMP_FLAVOUR=MP_FLAVOUR_GMP
-lcrypto -lssl -lgmp  certpatch.c   -o certpatch
/tmp/cc0iGLqy.o: In function `main':
certpatch.c:(.text+0x19c): undefined reference to
`OPENSSL_add_all_algorithms_noconf'
certpatch.c:(.text+0x1b5): undefined reference to `BIO_s_file'
certpatch.c:(.text+0x1bd): undefined reference to `BIO_new'
certpatch.c:(.text+0x1e5): undefined reference to `BIO_ctrl'
[snip]
certpatch.c:(.text+0x7b8): undefined reference to `PEM_write_bio_X509'
certpatch.c:(.text+0x7c4): undefined reference to `BIO_free'
collect2: error: ld returned 1 exit status
make[2]: *** [certpatch] Error 1
make[2]: Leaving directory `/tmp/buildd/isakmpd-20041012/apps/certpatch'

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

Patch attached (originally proposed in bug #622051).
Description: fix build with ld --as-needed
 libraries must be placed behind the objects needing them,
 else their symbols will not be registered as needed leading to
 undefined references when compiling with ld --as-needed
 LDFLAGS is placed before the objects, LOADLIBES is the correct
 implicit rule variable for library linking
Author: Julian Taylor <[email protected]>
Index: isakmpd-20041012/apps/certpatch/GNUmakefile
===================================================================
--- isakmpd-20041012.orig/apps/certpatch/GNUmakefile	2011-07-14 11:50:28.433075567 +0000
+++ isakmpd-20041012/apps/certpatch/GNUmakefile	2011-07-14 11:51:24.903075591 +0000
@@ -39,7 +39,7 @@
 FEATURES!=	awk '/^FEATURES=/ { print $$0 }' ${.CURDIR}/../../Makefile | sed 's/FEATURES=.//'
 .PATH:		${TOPSRC} ${TOPSRC}/sysdep/${OS} ${TOPOBJ}
 CFLAGS+=	-I${TOPSRC} -I${TOPSRC}/sysdep/${OS} -I${TOPOBJ} -Wall
-LDFLAGS+=	-lcrypto -lssl -lgmp
+LOADLIBES+=	-lcrypto -lssl -lgmp
 MAN=		certpatch.8
 
 CFLAGS+=	-DMP_FLAVOUR=MP_FLAVOUR_GMP

Reply via email to