Prevent libtool from moving flags

Akim Demaille <[email protected]>
Newsgroups gmane.comp.gnu.libtool.general
Message-ID <[email protected]>
Hi!

I have a library that, when loading, invokes functions in the main application.  So dependencies are really resolved in reverse: the main program does not "need" the libraries, it is the libraries that use the main program to inform it that they are there.

In such a case, some distros, such as Ubuntu, will completely drop the dependency on the library.  The workaround is well known: use -Wl,--no-as-needed.

Unfortunately, libtool moves the options around, and since -Wl,--(no-)?-as-needed applies to the libraries that are _after_ it, the result is disastrous:

# ./libtool --tag=CXX --mode=link g++-4.9 -Xlinker --no-as-needed -Wl,--no-as-needed -g -O2 -std=c++14 -avoid-version -module -L/usr/lib/python3.4/config-3.4m-x86_64-linux-gnu -L/usr/lib -lpthread -ldl  -lutil -lm  -lpython3.4m -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -o python/vcsn_cxx.la -rpath /usr/local/lib/python3.4/site-packages python/python_vcsn_cxx_la-vcsn_cxx.lo -lboost_python-py34 -lpthread -ldl  -lutil -lm  -lpython3.4m lib/liblal_char_b.la  lib/liblal_char_q.la  lib/liblal_char_z.la lib/libvcsn.la
libtool: warning: '/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libltdl.la' seems to be moved
libtool: link: rm -fr  python/.libs/vcsn_cxx.la python/.libs/vcsn_cxx.lai python/.libs/vcsn_cxx.so
libtool: link: g++-4.9  -fPIC -DPIC -shared -nostdlib /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.9/crtbeginS.o  python/.libs/python_vcsn_cxx_la-vcsn_cxx.o   -Wl,-rpath -Wl,/build/vcsn/_build/lib/.libs -Wl,-rpath -Wl,/usr/local/lib/vcsn -L/usr/lib/python3.4/config-3.4m-x86_64-linux-gnu -L/usr/lib -lboost_python-py34 -lpthread -lutil -lpython3.4m lib/.libs/liblal_char_b.so lib/.libs/liblal_char_q.so lib/.libs/liblal_char_z.so lib/.libs/libvcsn.so -L/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu -lboost_filesystem -lboost_system /usr/lib/x86_64-linux-gnu/libltdl.so -ldl -lrt -L/usr/lib/gcc/x86_64-linux-gnu/4.9 -L/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gn
 u -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.9/../../.. -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/x86_64-linux-gnu/4.9/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crtn.o  -Wl,--no-as-needed -Wl,--no-as-needed -g -O2 -Wl,-export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions   -pthread -Wl,-soname -Wl,vcsn_cxx.so -o python/.libs/vcsn_cxx.so
libtool: link: ( cd "python/.libs" && rm -f "vcsn_cxx.la" && ln -s "../vcsn_cxx.la" "vcsn_cxx.la" )

So basically:

$ libtool --tag=CXX --mode=link g++-4.9 -Wl,--no-as-needed lib/liblal_char_b.la ...

becomes

$ g++-4.9 lib/liblal_char_b.la...  -Wl,--no-as-needed

so -Wl,--no-as-needed has no effects, it is too late.

I have read the faq, and I do know that there is a workaround: "./configure CXX='g++ -Wl,--no-as-needed'", and yes it works.  But I meant to say that it would be nice if options could stay where they are :)

Cheers!
_______________________________________________
https://lists.gnu.org/mailman/listinfo/libtool
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.