Subject: Re: libtool, C++ shared libraries, and pthreads
To: None <tech-pkg@NetBSD.org>
From: Johnny C. Lam <jlam@buildlink.org>
List: tech-pkg
Date: 11/11/2004 16:02:54
Todd Vierling wrote:
> On Thu, 11 Nov 2004, Johnny C. Lam wrote:
>
>
>>On NetBSD 2.0, libtool doesn't correctly generate C++ shared libraries
>>if the shared library should also link against -lpthread. Currently,
>>libtool uses:
>>
>> g++ -shared -nostdlib $predep_objects $libobjs $deplibs \
>> $postdep_objects $compiler_flags \
>> ${wl}-soname $wl$soname -o $lib $postdeps
>
>
> Yeah, that's not entirely right, but the problem is, this is the globally
> generated shlib link command for g++ on GNU ld. It's not a NetBSD-specific
> configuration.
>
> There's a way to fix this in the current libtool, however, until this is
> better addressed in libtool's upstream sources by not using -nostdlib: on
> NetBSD, in ltmain.sh, make -pthread trigger -lpthread automagically. This
> is easy to do, so I'll go implement and test it now. (It's not
> unprecedented; there's a special case for {Open,Free}BSD to omit -lc_r if
> supplied in favor of -pthread.)
I've attached the essential part of the changes to libtool that I wish
to make to fix the libtool.m4 that differ from the current changes in
manual-libtool.m4. This correctly links -lpthread to the shared library
when I build comms/gsmlib.
One side effect of this change is that the installed libtool archive no
longer lists any of "-lstdc++ -lpthread -lgcc_s" in the dependency_libs
line, although the shared library dependencies are still recorded in the
shared library. I think this is okay, but does anyone see any problems
that may arise as a result?
Thanks,
-- Johnny Lam <jlam@buildlink.org>