Re: postdeps empty on OpenBSD
Hi Olly, Brad, [ quoting generously for the benefit of Brad; this thread is also at http://lists.gnu.org/archive/html/libtool/2005-09/msg00070.html ] * Olly Betts wrote on Tue, Sep 20, 2005 at 08:08:40PM CEST: > I'm trying to link C++ code into a shared object for use as a Python > module. I'm using libtool to do the linking. On Linux this works > well, but on OpenBSD it fails with lots of C++ library symbols not > found. > > The problem seems to be that on OpenBSD the shared object doesn't > pull in libstdc++. Python isn't written in C++, so doesn't pull in > libstdc++ either. > > I've found that if I explicitly link with -lstdc++ then it works on > OpenBSD, which supports this theory. I could potentially just always > explicitly link with -lstdc++, but I'm concerned that this could try > to link in two different versions on a machine with multiple compilers > installed. > > Comparing the generated libtool scripts on the 2 systems, I've noticed > that postdeps is empty on OpenBSD. On Linux it is: > > postdeps="-lstdc++ -lm -lgcc -lc -lgcc" > > So this would seem to be on the right track. > > I don't entirely follow the logic which generates this, but it seems > to come from the output of something like: > > g++ -shared -v /dev/null 2>&1|grep "\-L" > > On an x86 Linux box (Debian unstable) with g++ 3.3.6 this gives: > > /usr/bin/../lib/gcc-lib/i486-linux-gnu/3.3.6/collect2 --eh-frame-hdr -m > elf_i386 -shared /usr/bin/../lib/gcc-lib/i486-linux-gnu/3.3.6/../../../crti.o > /usr/bin/../lib/gcc-lib/i486-linux-gnu/3.3.6/crtbeginS.o > -L/usr/bin/../lib/gcc-lib/i486-linux-gnu/3.3.6 -L/usr/bin/../lib/gcc-lib > -L/usr/lib/gcc-lib/i486-linux-gnu/3.3.6 > -L/usr/bin/../lib/gcc-lib/i486-linux-gnu/3.3.6/../../.. > -L/usr/lib/gcc-lib/i486-linux-gnu/3.3.6/../../.. /dev/null -lstdc++ -lm > -lgcc_s -lc -lgcc_s /usr/bin/../lib/gcc-lib/i486-linux-gnu/3.3.6/crtendS.o > /usr/bin/../lib/gcc-lib/i486-linux-gnu/3.3.6/../../../crtn.o > > On an x86 OpenBSD 3.7 box with g++ 3.3.5 this gives: > > /usr/lib/gcc-lib/i386-unknown-openbsd3.7/3.3.5/collect2 --eh-frame-hdr > -shared -Bdynamic -dynamic-linker /usr/libexec/ld.so /usr/lib/crtbeginS.o > -L/usr/lib/gcc-lib/i386-unknown-openbsd3.7/3.3.5 /dev/null -lsupc++ -lgcc > -lgcc /usr/lib/crtendS.o > > Note: -lsupc++ instead of -lstdc++. > > If I remove the "-shared" on OpenBSD I get -lstdc++ instead of -lsupc++. > > I don't know if it's relevant, but both systems have shared and static > versions > of libstdc++, but only static versions of libsupc++ and libgcc. The Linux > system has a shared (only) libgcc_s, but the OpenBSD system doesn't have this > at all. > > Is this a libtool issue, or should I be looking elsewhere? Probably libtool needs to be adjusted (on OpenBSD, output_verbose_link_cmd is set to `echo' in the C++ case). Brad, you changed this with this patch: http://lists.gnu.org/archive/html/libtool-patches/2004-07/msg0.html and presumably for good reason. However, I could not find the corresponding discussion by searching of web archives. Unfortunately, I don't have access to OpenBSD, either, at the moment, to test myself. Could you be bothered to look at this issue? Thanks, Ralf ___ http://lists.gnu.org/mailman/listinfo/libtool
Re: postdeps empty on OpenBSD
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ralf Wildenhues wrote: | | Probably libtool needs to be adjusted (on OpenBSD, | output_verbose_link_cmd is set to `echo' in the C++ case). | | Brad, you changed this with this patch: | http://lists.gnu.org/archive/html/libtool-patches/2004-07/msg0.html | and presumably for good reason. However, I could not find the | corresponding discussion by searching of web archives. Unfortunately, I | don't have access to OpenBSD, either, at the moment, to test myself. | | Could you be bothered to look at this issue? IIRC, archive_cmds on openbsd does not use -nostdlib, so having empty postdeps ought to be okay. Olly may have found that it is not okay though :( Peter -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.0 (Darwin) iQCVAwUBQzEojbiDAg3OZTLPAQLgZgP/Xb3mgWsyw8Z0BFTs+UqU0tFoLE1+JoHP ncNdbfbghMjX2poqHyqKrUTcC7Rfvlp4SNfW1h50NkNBIemLqXC3qal83aBmeTOo LrLsmBijJpdEZLJDqgHQSb9LQWX95PQaU1LDiT2LEIM3RlzWYwirXXbSEJ4I8zds tnnjzooiVO8= =m1k8 -END PGP SIGNATURE- ___ http://lists.gnu.org/mailman/listinfo/libtool
Re: postdeps empty on OpenBSD
* Peter O'Gorman wrote on Wed, Sep 21, 2005 at 11:31:58AM CEST: > Ralf Wildenhues wrote: > | > | Probably libtool needs to be adjusted (on OpenBSD, > | output_verbose_link_cmd is set to `echo' in the C++ case). > | > | Brad, you changed this with this patch: > | http://lists.gnu.org/archive/html/libtool-patches/2004-07/msg0.html > | and presumably for good reason. However, I could not find the > | corresponding discussion by searching of web archives. Unfortunately, I > | don't have access to OpenBSD, either, at the moment, to test myself. > IIRC, archive_cmds on openbsd does not use -nostdlib, so having empty > postdeps ought to be okay. Good point. > Olly may have found that it is not okay though :( Olly, can you show us the libtool link line that fails, plus the output it generates (you can probably cut off after the first ten or so errors to keep size down). Thanks, Ralf ___ http://lists.gnu.org/mailman/listinfo/libtool
Re: postdeps empty on OpenBSD
On 2005-09-21, Peter O'Gorman <[EMAIL PROTECTED]> wrote: > IIRC, archive_cmds on openbsd does not use -nostdlib, so having empty > postdeps ought to be okay. It looks like the problem is that "g++ -shared" doesn't link to libstdc++. Here's the output from my original message (except wrapped for your viewing pleasure): g++ -shared -v /dev/null 2>&1|grep "\-L" [...] On an x86 OpenBSD 3.7 box with g++ 3.3.5 this gives: /usr/lib/gcc-lib/i386-unknown-openbsd3.7/3.3.5/collect2 --eh-frame-hdr -shared -Bdynamic -dynamic-linker /usr/libexec/ld.so /usr/lib/crtbeginS.o -L/usr/lib/gcc-lib/i386-unknown-openbsd3.7/3.3.5 /dev/null -lsupc++ -lgcc -lgcc /usr/lib/crtendS.o Note: -lsupc++ instead of -lstdc++. Without the -shared, the output *does* contain -lstdc++. So using "g++ -shared" to do the link means my module doesn't depend on libstdc++. With dlopen from a C++ program that would be OK, as the program would pull in libstdc++, but dlopen from a C program fails. Cheers, Olly ___ http://lists.gnu.org/mailman/listinfo/libtool
Re: postdeps empty on OpenBSD
On Wed, Sep 21, 2005 at 05:05:53PM +0200, Ralf Wildenhues wrote: > Olly, can you show us the libtool link line that fails, plus the output > it generates (you can probably cut off after the first ten or so > errors to keep size down). The libtool link doesn't fail. The failure comes when Python tries to dlopen the resulting module. Here's the libtool link line (from the output from "make"): /bin/sh ../libtool --tag=CXX --mode=link g++ -Wall -Wno-unused -Wno-uninitialized -g -I/home/olly/install/include -o _xapian.la -rpath /usr/local/lib/python2.3/site-packages -avoid-version -module -no-undefined xapian_wrap.lo /home/olly/install/lib/libxapian.la rm -fr .libs/_xapian.la .libs/_xapian.lai .libs/_xapian.so g++ -shared -fPIC -DPIC .libs/xapian_wrap.o -L/home/olly/install/lib -lxapian -o .libs/_xapian.so creating _xapian.la (cd .libs && rm -f _xapian.la && ln -s ../_xapian.la _xapian.la) And here's the error when Python tries to load it: $ PYTHONPATH=/home/olly/xb-install-tmp:. python -c 'import xapian' python:/usr/local/lib/libxapian.so.8.0: undefined symbol '_ZTISi' python: /usr/local/lib/libxapian.so.8.0: can't resolve reference '_ZTISi' python:/usr/local/lib/libxapian.so.8.0: undefined symbol '_ZTISi' python: /usr/local/lib/libxapian.so.8.0: can't resolve reference '_ZTISi' python:/usr/local/lib/libxapian.so.8.0: undefined symbol '_ZTISi' python: /usr/local/lib/libxapian.so.8.0: can't resolve reference '_ZTISi' python:/usr/local/lib/libxapian.so.8.0: undefined symbol '_ZNSiD1Ev' python: /usr/local/lib/libxapian.so.8.0: can't resolve reference '_ZNSiD1Ev' [And lots more!] Demangling with c++filt, "_ZTISi" is "typeinfo for std::basic_istream >". The other symbols are all C++ STL stuff too from what I could see. Cheers, Olly ___ http://lists.gnu.org/mailman/listinfo/libtool
Re: postdeps empty on OpenBSD
On Wed, Sep 21, 2005 at 05:05:53PM +0200, Ralf Wildenhues wrote: > * Peter O'Gorman wrote on Wed, Sep 21, 2005 at 11:31:58AM CEST: > > Ralf Wildenhues wrote: > > | > > | Probably libtool needs to be adjusted (on OpenBSD, > > | output_verbose_link_cmd is set to `echo' in the C++ case). > > | > > | Brad, you changed this with this patch: > > | http://lists.gnu.org/archive/html/libtool-patches/2004-07/msg0.html > > | and presumably for good reason. However, I could not find the > > | corresponding discussion by searching of web archives. Unfortunately, I > > | don't have access to OpenBSD, either, at the moment, to test myself. > > > IIRC, archive_cmds on openbsd does not use -nostdlib, so having empty > > postdeps ought to be okay. > > Good point. > > > Olly may have found that it is not okay though :( > > Olly, can you show us the libtool link line that fails, plus the output > it generates (you can probably cut off after the first ten or so > errors to keep size down). > > Thanks, > Ralf Unfortunately I don't remember the details at the moment but I know that we ran into a number of linking issues with C++ based programs if output_verbose_link_cmd was left as is. Issues that our linker seemed to deal with just fine without libtool trying to explicitly doing something. I'll see if I can dig up any clues. ___ http://lists.gnu.org/mailman/listinfo/libtool
Re: postdeps empty on OpenBSD
Olly Betts dixit: >On 2005-09-21, Peter O'Gorman <[EMAIL PROTECTED]> wrote: >> IIRC, archive_cmds on openbsd does not use -nostdlib, so having empty >> postdeps ought to be okay. > >It looks like the problem is that "g++ -shared" doesn't link to libstdc++. gcc -shared creates a shared library. On OpenBSD, shared libraries do not link against other shared libraries. The main programme must link against all these. //mirabile -- I believe no one can invent an algorithm. One just happens to hit upon it when God enlightens him. Or only God invents algorithms, we merely copy them. If you don't believe in God, just consider God as Nature if you won't deny existence. -- Coywolf Qi Hunt ___ http://lists.gnu.org/mailman/listinfo/libtool
Re: postdeps empty on OpenBSD
Hi Thorsten, * Thorsten Glaser wrote on Wed, Sep 21, 2005 at 10:05:53PM CEST: > Olly Betts dixit: > >On 2005-09-21, Peter O'Gorman <[EMAIL PROTECTED]> wrote: > >> IIRC, archive_cmds on openbsd does not use -nostdlib, so having empty > >> postdeps ought to be okay. > > > >It looks like the problem is that "g++ -shared" doesn't link to libstdc++. > > gcc -shared creates a shared library. > > On OpenBSD, shared libraries do not link against other shared libraries. > The main programme must link against all these. OK, but this is exactly one thing libtool was designed to do for you: keep track of the libraries you also have to link against; it should have added -lstdc++ to _xapian.la's dependency_libs. Cheers, Ralf ___ http://lists.gnu.org/mailman/listinfo/libtool
Re: postdeps empty on OpenBSD
On Wed, Sep 21, 2005 at 10:45:40PM +0200, Ralf Wildenhues wrote: > * Thorsten Glaser wrote on Wed, Sep 21, 2005 at 10:05:53PM CEST: > > Olly Betts dixit: > > >It looks like the problem is that "g++ -shared" doesn't link to libstdc++. > > > > gcc -shared creates a shared library. > > > > On OpenBSD, shared libraries do not link against other shared libraries. > > The main programme must link against all these. Does that apply when using dlopen? When python dlopens _xapian.so, something automatically knows to load libxapian.so.8.0 too - so there's definitely a working shared library dependency mechanism in this case. The bottom line for me is that if I explicitly add "-lstdc++" when linking _xapian.so, it all works. If I don't, it doesn't. So I kind of feel that ideally libtool should be doing that for me... > OK, but this is exactly one thing libtool was designed to do for you: > keep track of the libraries you also have to link against; it should > have added -lstdc++ to _xapian.la's dependency_libs. It definitely isn't doing that. This is what I have in _xapian.la: dependency_libs=' /home/olly/install/lib/libxapian.la' But unless python uses ltdl that wouldn't help me here anyway. Cheers, Olly ___ http://lists.gnu.org/mailman/listinfo/libtool
Re: postdeps empty on OpenBSD
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Thorsten Glaser wrote: | gcc -shared creates a shared library. | | On OpenBSD, shared libraries do not link against other shared libraries. | The main programme must link against all these. Is there a reason for this? Peter -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.0 (Darwin) iQCVAwUBQzI5/LiDAg3OZTLPAQK1kwP+JiucDmdq2ufMrVZRwHd948c2+f75WSCA 0xhldTuA0ho2OZR7v67jEbHxS63FkTTMxep3kedQkHZsWOa/GNGz5k0K4OM52tqJ bRu47GvQuca4oFofYJ9CNBbMqQL4/Ijk/Nl9Jh7zQfoC459mmm6qoFwLsZGb+3a+ w4VpxfPpGag= =t+pK -END PGP SIGNATURE- ___ http://lists.gnu.org/mailman/listinfo/libtool