Subject: bug#12880: Incorrect handling -Wl,--no-as-needed with libtool 2.4.2

From: Quanah Gibson-Mount <[email-masked]>
Date: Tue, 13 Nov 2012 12:47:10 -0800

I've noticed that libtool re-orders -Wl,-no-as-needed incorrectly.

For example:

 /bin/bash ./libtool --tag=CC   --mode=link gcc  -Wall -Wno-format -pipe 
-O3 -DNDEBUG -Wl,--no-as-needed -lm -avoid-version -shrext .so -L. -o 
libmod_convert.la -rpath /usr/local/lib libmod_convert_la-mod_convert.lo 
libconverter.a -ldl

The purpose of this is to force linking of -lm into the resulting object. 
However, when libtool re-orders this linking command and passes it to gcc, 
the result is:

libtool: link: gcc -shared  -fPIC -DPIC 
.libs/libmod_convert_la-mod_convert.o   -lm -L. libconverter.a -ldl  -O3 
-Wl,--no-as-needed   -Wl,-soname -Wl,libmod_convert.so -o 
.libs/libmod_convert.so

As you can see, the -Wl,--no-as-needed flag is moved *after* the call to 
link in libm.

I could not find any way in which to get libtool to correctly pass the 
linking flags to gcc.  A search via google seems to indicate this is a long 
standing known issue with libtool, as there is an extensive log in the 
debian bug reporter about it.

Since there is no bug reporter for libtool that I could find, I have no 
idea if it was ever reported upstream, although I would have thought so by 
now.

build@zre-ubuntu12-64:~/builds/UBUNTU12_64/main/20121113050101_NETWORK/ZimbraConvertd/src/c$ 
./libtool --version
libtool (GNU libtool) 2.4.2

I finally restored to completely disabling gcc as-needed in my gcc spec 
file so that the library would be built properly.

Thanks,
Quanah

--

Quanah Gibson-Mount
Sr. Member of Technical Staff
Zimbra, Inc
A Division of VMware, Inc.
--------------------
Zimbra ::  the leader in open source messaging and collaboration