Modify

Ticket #6165 (closed Bugs: fixed)

Opened 2 years ago

Last modified 21 months ago

BOOST_ENABLE_THREADS/BOOST_DISABLE_THREADS wrongly configured on GCC 4.7

Reported by: Ai Azuma <ai.azuma@…> Owned by: johnmaddock
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

libstdcpp3.hpp.patch Download (631 bytes) - added by Ai Azuma <ai.azuma@…> 2 years ago.
boost-1.48.0-gcc47-winthreads.patch Download (710 bytes) - added by t.sailer@… 2 years ago.
Threading Detection fix for gcc 4.7/mingw32 target

Change History

Changed 2 years ago by Ai Azuma <ai.azuma@…>

comment:1 Changed 2 years ago by johnmaddock

  • Status changed from new to closed
  • Resolution set to fixed

(In [76133]) Fix threading detection in GCC-4.7 experimental. Fixes #6165.

comment:2 Changed 2 years ago by bkoz@…

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)

Changed 2 years ago by t.sailer@…

Threading Detection fix for gcc 4.7/mingw32 target

comment:3 Changed 2 years ago by t.sailer@…

  • Status changed from closed to reopened
  • Resolution fixed deleted

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:4 Changed 2 years ago by raptorfactor@…

comment:5 Changed 2 years ago by raptorfactor@…

Oops, I just noticed Thomas has already posted it. Durrr. Sorry for the noise.

comment:6 Changed 2 years ago by anonymous

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 Changed 2 years ago by t.sailer@…

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 Changed 2 years ago by anonymous

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 Changed 2 years ago by t.sailer@…

$ 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 Changed 2 years ago by t.sailer@…

/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 Changed 2 years ago by johnmaddock

  • Status changed from reopened to closed
  • Resolution set to fixed

(In [76594]) Enable thread support unconditionally on Win32 - it's not clear that this is the right thing to do, but it does seem to be needed for gcc-4.7 on Mingw and Cygwin. Fixes #6165.

comment:12 Changed 21 months ago by pwouters@…

It seems to still be broken on fedora with boost-1.48.0-13

comment:13 Changed 21 months ago by anonymous

The patch was first released in 1.49.0.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.