How can I keep -lstdc++ out of $postdeps?

Jack Bates <[email protected]>
Newsgroups gmane.comp.gnu.libtool.general
Message-ID <[email protected]>
How can I avoid dynamically linking with libstdc++?
or, how can I keep -lstdc++ out of $postdeps?

When I run "./configure CXXFLAGS=-static-libstdc++",
_LT_SYS_HIDDEN_LIBDEPS (in libtool.m4) runs the following command:


   $CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured 
with:" | $GREP "\-L"


Which expands to:


   c++ -shared -static-libstdc++ -std=c++11 -v conftest.o 2>&1 | 
/bin/grep -v ^Configured with: | /bin/grep -L


When I run that command myself, the output is:


   /usr/lib/gcc/x86_64-linux-gnu/6/collect2 -plugin 
/usr/lib/gcc/x86_64-linux-gnu/6/liblto_plugin.so 
-plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper 
-plugin-opt=-fresolution=/tmp/cc4DFGDe.res 
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc 
-plugin-opt=-pass-through=-lgcc_s --sysroot=/ --build-id --eh-frame-hdr 
-m elf_x86_64 --hash-style=gnu -shared 
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/crti.o 
/usr/lib/gcc/x86_64-linux-gnu/6/crtbeginS.o 
-L/usr/lib/gcc/x86_64-linux-gnu/6 
-L/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu 
-L/usr/lib/gcc/x86_64-linux-gnu/6/../../../../lib 
-L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu 
-L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/6/../../.. conftest.o 
-Bstatic -lstdc++ -Bdynamic -lm -lgcc_s -lc -lgcc_s 
/usr/lib/gcc/x86_64-linux-gnu/6/crtendS.o 
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/crtn.o


So the output contains "-Bstatic -lstdc++",
but $postdeps in the generated ./libtool is:


   postdeps="-lstdc++ -lm -lgcc_s -lc -lgcc_s"


So although conftest.o respects -static-libstdc++ and is not dynamically 
linked with libstdc++,
the rest of my project, when eventually built, *is* :-(

Now, if I edit ./libtool and set postdeps="", my project builds just 
fine (as far as I can tell ...). The compiler/linker already 
adds/doesn't add those dynamic links as appropriate. So is that an 
option? Is there a recommended way to disable _LT_SYS_HIDDEN_LIBDEPS?

Alternatively, should _LT_SYS_HIDDEN_LIBDEPS respect the -B option -- 
either adding it to $postdeps or ignoring other options between -Bstatic 
and -Bdynamic?

Thanks!

_______________________________________________
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.