Subject: Re: libtool, C++ shared libraries, and pthreads
To: None <>
From: Todd Vierling <>
List: tech-pkg
Date: 11/11/2004 13:35:26
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

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, 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.)

Given that NetBSD 2.0 is not yet released, I don't know whether this would
warrant a PKGREVISION bump, and if so, where such a bump would be needed.
Perhaps we should forego the bump if this is fixed correctly before 2.0 hits
the FTP shelves.

> The question is whether this command does the right thing on NetBSD<2.0.
> Although GCC on NetBSD 1.6.x doesn't support -pthread, I wonder if it
> properly adds the relevant /usr/lib/crt*.o objects, -lstdc++, etc.

Yes.  I fixed "{gcc,c++} -shared" between 1.4 and 1.5.

-- Todd Vierling <> <>