libstdc++: '_GLIBCXX_HAS_GTHREADS' -- '__GTHREADS' vs. '__GTHREADS_CXX0X'
Thomas Schwinge
tschwinge@baylibre.com
Thu Feb 20 12:29:10 GMT 2025
Hi!
I'm still working on libstdc++ support for GCC's GPU targets: GCN, nvptx.
These configurations are (in typical use) multi-threaded, and support
mutexes etc., but they don't support dynamic spawning of threads etc.
Therefore, re 'libgcc/gthr.h', they define '__GTHREADS' but *not*
'__GTHREADS_CXX0X'. (See 'libgcc/config/gcn/gthr-gcn.h'; nvptx still to
be done, currently 'Thread model: single', very likely bogus...)
Now, 'libstdc++-v3/acinclude.m4:GLIBCXX_CHECK_GTHREADS' does:
[...]
AC_MSG_CHECKING([for gthreads library])
AC_TRY_COMPILE([#include "gthr.h"],
[
#ifndef __GTHREADS_CXX0X
#error
#endif
], [ac_has_gthreads=yes], [ac_has_gthreads=no])
else
ac_has_gthreads=no
fi
AC_MSG_RESULT([$ac_has_gthreads])
if test x"$ac_has_gthreads" = x"yes"; then
AC_DEFINE(_GLIBCXX_HAS_GTHREADS, 1,
[Define if gthreads library is available.])
[...]
That is, it defines '_GLIBCXX_HAS_GTHREADS' per '__GTHREADS_CXX0X'.
Dependent on this '_GLIBCXX_HAS_GTHREADS',
'libstdc++-v3/include/bits/std_mutex.h' then enables 'class mutex'. In
other words, in the current GCN configuration ('__GTHREADS', but not
'__GTHREADS_CXX0X'), 'class mutex' (and probably more) is not available,
which leads to build issues (and presumably a lot of noise in the test
suite).
Is '__GTHREADS != __GTHREADS_CXX0X' simply a configuration that libstdc++
so far has not attempted to support? To make that work, do we need to
consider '__GTHREADS' vs. '__GTHREADS_CXX0X' individually in libstdc++,
for guarding the respective features?
Grüße
Thomas
More information about the Libstdc++
mailing list