Boost logo

Boost-Build :

Subject: Re: [Boost-build] Default threading model in Linux
From: Vladimir Prus (ghost_at_[hidden])
Date: 2008-11-09 12:41:33


On Sunday 09 November 2008 20:16:42 Joaquin M Lopez Munoz wrote:
> Vladimir Prus <ghost <at> cs.msu.su> writes:
>
> >
> > On Sunday 09 November 2008 19:16:39 Joaquin M Lopez Munoz wrote:
> > >
> > > No, I'm referring to the threading model assumed when, for instance,
> > > building a test with
> > >
> > > test-suite "foo" : [ run foo.cpp ] ;
> > >
> > > So, threading=single is assumed here, right?
> >
> > I don't understand what "assumed" means. When every target is built,
> > all non-optional feature has a specific value -- there's nothing
> > to "assume". Unless you did something to force MT, threading=single
> > will be in effect.
>
> Here, by "assumed" I meant "by default". So, threading=single
> is the default unless otherwise specified.
>
> > > That poses a
> > > small problem, as on the other hand BOOST_HAS_THREADS and
> > > BOOST_HAS_PTHREADS seem to be unconditionally defined,
> >
> > By what code? On gcc, those are set only if -pthread is added to gcc
> > options during compilation.
>
> Here's where my observations differ: I'm using gmane to write
> this, so I can't attach files, the following are pasted inline:
>
> ***Jamfile.v2***
> test-suite "foo_test" : [ run foo.cpp ] ;
>
> ***foo.cpp***
> #include <boost/config.hpp>
> #include <iostream>
>
> int main()
> {
> std::cout<<"BOOST_HAS_THREADS "
> #if defined(BOOST_HAS_THREADS)
> "defined\n";
> #else
> "undefined\n";
> #endif
>
> std::cout<<"BOOST_HAS_PTHREADS "
> #if defined(BOOST_HAS_PTHREADS)
> "defined\n";
> #else
> "undefined\n";
> #endif
>
> return 1;
> }
>
> Put these two files under a folder foo in boost/libs and
> play with bjam and different settings or threading:
>
> GCC under Cygwin:
> threading=single
> BOOST_HAS_THREADS defined
> BOOST_HAS_PTHREADS defined

This is happening for me on Linux, too. There's no -pthread in gcc command
line, so either Boost.Config is wrong, or libstdc++ is back to setting symbols
it has no business setting (like _REENTRANT).

> threading=multi
> BOOST_HAS_THREADS defined
> BOOST_HAS_PTHREADS defined
>
> MSVC 8.0:
> threading=single
> BOOST_HAS_THREADS defined
> BOOST_HAS_PTHREADS undefined

What target path is used? MSVC 8.0 does not have single-threaded shared
runtime, so it forces threading=multi.

- Volodya


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk