libstdc++: '_GLIBCXX_HAS_GTHREADS' -- '__GTHREADS' vs. '__GTHREADS_CXX0X'
Jonathan Wakely
jwakely@redhat.com
Thu Feb 20 17:52:17 GMT 2025
It looks like there's another bug in src/c++20/format.cc
#ifndef _GLIBCXX_HAS_GTHREADS
// Dummy mutex
struct mutex
{
void lock() const { }
void unlock() const { }
};
#endif
This will mean that a target that does support parallelism but doesn't
support __GTHREADS_CXX0X will use a dummy mutex that doesn't actually
prevent concurrent execution. This won't cause a build failure, just
data races and undefined behaviour :-(
So you probably want a similar fix here for nvptx:
--- a/libstdc++-v3/src/c++20/format.cc
+++ b/libstdc++-v3/src/c++20/format.cc
@@ -49,13 +49,16 @@ namespace __format
#if defined _GLIBCXX_USE_NL_LANGINFO_L && __CHAR_BIT__ == 8
namespace
{
-#ifndef _GLIBCXX_HAS_GTHREADS
+#ifndef __GTHREADS
// Dummy mutex
struct mutex
{
void lock() const { }
void unlock() const { }
};
+#elif ! defined _GLIBCXX_HAS_GTHREADS
+// Use __gnu_cxx::__mutex if std::mutex isn't available.
+using mutex = __gnu_cxx::__mutex;
#endif
// A non-standard locale::facet that caches the locale's std::text_encoding
I've created https://gcc.gnu.org/PR118960 to clean all this up for GCC 16.
More information about the Libstdc++
mailing list