#6165 closed Bugs (fixed)
BOOST_ENABLE_THREADS/BOOST_DISABLE_THREADS wrongly configured on GCC 4.7
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | To Be Determined | Component: | config |
Version: | Boost 1.48.0 | Severity: | Problem |
Keywords: | Cc: |
Description
I find that Boost.Thread and other components in Boost that depend on thread support does not work on recent weekly snapshots of GCC trunk (GCC 4.7.0 experimental) on Ubuntu 10.04.3 LTS 64 bit because BOOST_ENABLE_THREADS is not defined on my environment and BOOST_DISABLE_THREADS is.
The origin of this failure could be due to the change of macro definitions in GCC trunk. Now, GCC 4.7 (with -pthread option, of course) defines not the macro _GLIBCXX_HAVE_GTHR_DEFAULT but another macro _GLIBCXX_HAS_GTHREADS. Thus, BOOST_ENABLE_THREADS and BOOST_DISABLE_THREADS are wrongly configured in boost/config/stdlib/libstdcpp3.hpp.
The attached patch seems to work for me, but I'm not sure how to detect thread support on GCC/libstdc++ correctly...
Attachments (2)
Change History (15)
by , 11 years ago
Attachment: | libstdcpp3.hpp.patch added |
---|
comment:1 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 by , 11 years ago
For 4.7, this is
# if defined(_GLIBCXX_HAS_GTHREADS)
For 4.6 and others, this should be
# if defined(_GLIBCXX_HAVE_GTHR_DEFAULT) \
defined(_GLIBCXXPTHREADS)
by , 11 years ago
Attachment: | boost-1.48.0-gcc47-winthreads.patch added |
---|
Threading Detection fix for gcc 4.7/mingw32 target
comment:3 by , 11 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
The threading detection doesn't yet work for gcc 4.7 with the mingw32 target.
mingw32 gcc defines (for some time already) GLIBCXX. Up to 4.6, it used to define _GLIBCXX_HAVE_GTHR_DEFAULT as well, that's why it worked up to 4.6.
Now 4.7 no longer defines _GLIBCXX_HAVE_GTHR_DEFAULT, which prevents threading from compiling.
comment:5 by , 11 years ago
Oops, I just noticed Thomas has already posted it. Durrr. Sorry for the noise.
comment:6 by , 11 years ago
What does bits/c++config.h do to detect when it's being build with --enable-threads ? There must be some such macro even if it's name has changed?
Thanks, John.
comment:7 by , 11 years ago
Interestingly, I do not have bits/c++config.h in my mingw32 gcc installation.
gcc defines _MT if -mthreads is given on the command line (and that is the only difference).
comment:8 by , 11 years ago
gcc defines _MT if -mthreads is given on the command line (and that is the only difference).
I'm not convinced that's the right thing to check - ideally what we want to know is "what configure options was libstdc++ compiled with?", and then set BOOST_HAS_THREADS uniformly based on that.
Can someone please grep the headers for _GLIBCXX_HAS_GTHREADS: there should be a preprocessor based switch statement somewhere that selects which threading behaviour to use, and that's what we need to hook into.
Thanks, John.
comment:9 by , 11 years ago
$ find /usr/lib64/gcc/i686-pc-mingw32/4.7.0/include /usr/i686-pc-mingw32/sys-root/mingw/include/ |xargs grep _GLIBCXX_HAS_GTHREADS /usr/lib64/gcc/i686-pc-mingw32/4.7.0/include/c++/i686-pc-mingw32/bits/c++config.h:/* #undef _GLIBCXX_HAS_GTHREADS */ /usr/lib64/gcc/i686-pc-mingw32/4.7.0/include/c++/thread:#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) /usr/lib64/gcc/i686-pc-mingw32/4.7.0/include/c++/thread:#endif _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 /usr/lib64/gcc/i686-pc-mingw32/4.7.0/include/c++/mutex:#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) /usr/lib64/gcc/i686-pc-mingw32/4.7.0/include/c++/mutex:#endif _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 /usr/lib64/gcc/i686-pc-mingw32/4.7.0/include/c++/condition_variable:#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) /usr/lib64/gcc/i686-pc-mingw32/4.7.0/include/c++/condition_variable:#endif _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1 /usr/lib64/gcc/i686-pc-mingw32/4.7.0/include/c++/future:#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) \ /usr/lib64/gcc/i686-pc-mingw32/4.7.0/include/c++/future:#endif _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
I can't find any definition.
comment:10 by , 11 years ago
/usr/lib64/gcc/i686-pc-mingw32/4.7.0/include/c++/i686-pc-mingw32/bits/c++config.h has:
/* Define if gthreads library is available. */ /* #undef _GLIBCXX_HAS_GTHREADS */
/* Define if pthreads_num_processors_np is available in <pthread.h>. */ /* #undef _GLIBCXX_USE_PTHREADS_NUM_PROCESSORS_NP */
/* Define to 1 if mutex_timedlock is available. */ #define _GTHREAD_USE_MUTEX_TIMEDLOCK 1
I can't find anything else thread-related in there...
Is it even possible to not have threading on Win32?
comment:11 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
(In [76133]) Fix threading detection in GCC-4.7 experimental. Fixes #6165.