Package: asn1c
Version: 0.9.21.dfsg1-2
Severity: normal
Tags: upstream patch
User: debian-...@lists.debian.org
Usertags: ld-as-needed

asn1c fails to build when --as-needed linker option is enabled,
because of incorrect order of parameters passed to ld. Here's a log of
failed build in Ubuntu:
https://launchpad.net/ubuntu/+source/asn1c/0.9.21.dfsg1-2/+build/3942514

gcc -I. -DEMIT_ASN_DEBUG=0 -DNO_OVERFLOW_TESTS -g -O2 -fstack-protector 
--param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -Wshadow 
-Wcast-qual -Wcast-align -Wchar-subscripts -Wmissing-prototypes 
-Wmissing-declarations -o check-executable -lm *.c*
/tmp/ccjk3V35.o: In function `REAL__dump':
/build/buildd/asn1c-0.9.21.dfsg1/asn1c/tests/test-check-65/REAL.c:98: undefined 
reference to `ilogb'
/tmp/ccjk3V35.o: In function `asn_double2REAL':
/build/buildd/asn1c-0.9.21.dfsg1/asn1c/tests/test-check-65/REAL.c:528: 
undefined reference to `ilogb'
collect2: error: ld returned 1 exit status
make[5]: *** [check-executable] Error 1

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

The attached patch was used in Ubuntu to fix the problem.
https://launchpad.net/ubuntu/+source/asn1c/0.9.21.dfsg1-2ubuntu1

-- System Information:
Debian Release: wheezy/sid
  APT prefers quantal-updates
  APT policy: (500, 'quantal-updates'), (500, 'quantal-security'), (500, 
'quantal-proposed'), (500, 'quantal'), (100, 'quantal-backports')
Architecture: i386 (i686)

Kernel: Linux 3.5.0-18-generic (SMP w/2 CPU cores)
Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Description: fix FTBFS with --as-needed linker option
 Libraries must be placed after source files in command line.
Author: Ilya Barygin <randomact...@ubuntu.com>

--- asn1c-0.9.21.dfsg1.orig/asn1c/tests/check-assembly.sh
+++ asn1c-0.9.21.dfsg1/asn1c/tests/check-assembly.sh
@@ -48,7 +48,7 @@ CC ?= ${CC}
 all: check-executable
 check-executable: compiled-module *.c*
 	@rm -f *.core
-	\$(CC) \$(CFLAGS) -o check-executable -lm *.c*
+	\$(CC) \$(CFLAGS) -o check-executable *.c* -lm
 
 # Compile the corresponding .asn1 spec.
 compiled-module: ${asn_module} ../../asn1c

Reply via email to