Package: lebiniou
Version: 3.12-1
Severity: normal
Tags: upstream patch
User: debian-...@lists.debian.org
Usertags: ld-as-needed

Hello Olivier,

lebiniou fails to build when --as-needed linker option is enabled. Here's
a log of failed build in Ubuntu, where this option is on by default:
https://launchpad.net/ubuntu/+source/lebiniou/3.12-1/+build/2881998/+files/buildlog_ubuntu-precise-i386.lebiniou_3.12-1_FAILEDTOBUILD.txt.gz

There are two problems:
1. Executable is not linked with -lm, while a function from math library is
used.
2. Configure script puts detected libraries in LDFLAGS variable. When linking
the executable, LDFLAGS are passed before the object files, which leads to an
error with --as-needed.

Attached patch puts library flags to correct LIBS variable. It was applied in
Ubuntu:
https://launchpad.net/ubuntu/+source/lebiniou/3.12-1ubuntu1

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

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

Kernel: Linux 3.0.0-13-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 build with --as-needed linker option
 Put all library flags in LIBS instead of LDFLAGS.
Author: Ilya Barygin <randomact...@ubuntu.com>

--- lebiniou-3.12.orig/configure.ac
+++ lebiniou-3.12/configure.ac
@@ -50,20 +50,17 @@
 # glib-2.0
 PKG_CHECK_MODULES([GLIB], [glib-2.0], , [AC_MSG_ERROR([You must have libglib2.0-dev installed])])
 CPPFLAGS="$CPPFLAGS `pkg-config glib-2.0 --cflags`"
-LDFLAGS="$LDFLAGS `pkg-config glib-2.0 --libs`"
 
 # fftw3
 PKG_CHECK_MODULES([FFTW3], [fftw3], , [AC_MSG_ERROR([You must have libfftw3-dev installed])])
 CPPFLAGS="$CPPFLAGS `pkg-config fftw3 --cflags`"
-LDFLAGS="$LDFLAGS `pkg-config fftw3 --libs`"
 
 # libxml-2.0
 PKG_CHECK_MODULES([XML2], [libxml-2.0 >= 2.6.0], , [AC_MSG_ERROR([You must have libxml2-dev >= 2.6 installed])])
 CPPFLAGS="$CPPFLAGS `pkg-config libxml-2.0 --cflags`"
-LDFLAGS="$LDFLAGS `pkg-config libxml-2.0 --libs`"
 
 # zlib - we assume it's installed on most systems
-LDFLAGS="$LDFLAGS -lz"
+LIBS="${GLIB_LIBS} ${FFTW3_LIBS} ${XML2_LIBS} -lz -lm"
 
 # We need to know which prefix we used to find some default values
 if test "x${prefix}" = "xNONE"; then
@@ -257,13 +254,14 @@
   *)
     os_family=linux
     os_netbsd_or_openbsd=false
-    LDFLAGS="$LDFLAGS -ldl"
+    LIBS="$LIBS -ldl"
     DEFAULT_INPUT_PLUGIN=alsa
 esac
 AC_MSG_RESULT([$os_family])
 AM_CONDITIONAL([OS_LINUX_FAMILY], [test x"$os_family" = x"linux"])
 AM_CONDITIONAL([OS_NETBSD_OR_OPENBSD], [test x"$os_netbsd_or_openbsd" = x"true"])
 AC_DEFINE_UNQUOTED([DEFAULT_INPUT_PLUGIN], ["$DEFAULT_INPUT_PLUGIN"], [Default input plugin])
+AC_SUBST(LIBS)
 
 dnl ------------------------------------------------------------------
 dnl Options

Reply via email to