Boost logo

Boost :

From: Jonathan Wakely (cow_at_[hidden])
Date: 2004-05-13 04:51:58

On Thu, May 13, 2004 at 01:22:13PM +0400, Vladimir Prus wrote:

> > > So, for single threaded builds
> > > 1. Boost will think it's MT build and call pthread_* functions.
> > > 2. Toolset won't add '-pthread' to linker command line
> > >
> > > Bottom like: you'll get link failures for single-thread builds.
> >
> > We can fix that: we already have platforms/toolsets where the default, in
> > fact the *only* behaviour is for builds to be thread safe, even if you
> > specify <threading>single.
> I really don't think we want to disable <threading>signle for such a popular
> platform.

That's why we need G++ to define something whenever -pthread is given on
the command line. There's currently nothing suitable in GCC 3.4.
Ideally it would be defined for all platforms, since x86-linux isn't the
only non-windows system :)
Some platforms (e.g. NetBSD) automatically define _PTHREADS when -pthread
is given. It might be possible to do that for all systems. But there might
be good reasons not to.

> > I think the problem here is that we have two options for the <threading>
> > variant, but really we should have three:
> >
> > 1) threading must be on
> > 2) threading must be off
> > 3) whatever the default is for the compiler
> >
> > Most people actually want option (3) a lot of the time,
> Actually, I just don't want to pay for MT, unless I really mean to use the
> code in MT environment.

I understand (3) to mean MT when -pthread is given, single otherwise.

> > and currently
> > that's what <threading>single more or less gives you, ideally though we
> > would map builds for option 3 to either 1 or 2 so we don't build libraries
> > we've actually already built.
> I don't really understand the problem. For example, are there any compilers
> which generate MT code by default? And, what's "default for the compiler"?

The problem is that boost (currently) assumes you're compiling a MT app
if you use GCC 3.4, so the preprocessed output refers to the pthread_*
functions (which means G++ 3.4 _with_boost_ compiles MT by default)
which then causes linker errors if you didn't use -pthread.

If you manually define BOOST_DISABLE_THREADS then Boost doesn't refer to
the pthread_* functions and you don't need to give -pthread.


"A foolish consistency is the hobgoblin of little minds..."
	- Ralph Waldo Emerson

Boost list run by bdawes at, gregod at, cpdaniel at, john at