Fix 'libstdc++-v3/src/c++20/tzdb.cc' build for '__GTHREADS && !__GTHREADS_CXX0X' configurations (was: libstdc++: '_GLIBCXX_HAS_GTHREADS' -- '__GTHREADS' vs. '__GTHREADS_CXX0X')
Jonathan Wakely
jwakely@redhat.com
Thu Feb 20 17:31:39 GMT 2025
On Thu, 20 Feb 2025 at 17:28, Thomas Schwinge <tschwinge@baylibre.com> wrote:
>
> Hi!
>
> On 2025-02-20T16:36:56+0000, Jonathan Wakely <jwakely@redhat.com> wrote:
> > On 20/02/25 15:50 +0100, Thomas Schwinge wrote:
> >>From 820e015494e25187c9a5ffbd69911ec6ce612789 Mon Sep 17 00:00:00 2001
> >>From: Jonathan Wakely <jwakely@redhat.com>
> >>Date: Thu, 20 Feb 2025 14:08:11 +0000
> >>Subject: [PATCH] Fix 'libstdc++-v3/src/c++20/tzdb.cc' build for '__GTHREADS &&
> >> !__GTHREADS_CXX0X' configurations
> >>
> >> libstdc++-v3/
> >> * src/c++20/tzdb.cc [__GTHREADS && !__GTHREADS_CXX0X]: Use
> >> '__gnu_cxx::__mutex'.
> >>
> >>Co-authored-by: Thomas Schwinge <tschwinge@baylibre.com>
> >>---
> >> libstdc++-v3/src/c++20/tzdb.cc | 8 +++++++-
> >> 1 file changed, 7 insertions(+), 1 deletion(-)
> >>
> >>diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc
> >>index 7e8cce7ce8c..70ba7b0ef53 100644
> >>--- a/libstdc++-v3/src/c++20/tzdb.cc
> >>+++ b/libstdc++-v3/src/c++20/tzdb.cc
> >>@@ -35,6 +35,9 @@
> >> #include <atomic> // atomic<T*>, atomic<int>
> >> #include <memory> // atomic<shared_ptr<T>>
> >> #include <mutex> // mutex
> >>+#if defined __GTHREADS && ! defined _GLIBCXX_HAS_GHTREADS
> >>+# include <ext/concurrence.h> // __gnu_cxx::__mutex
> >>+#endif
> >> #include <filesystem> // filesystem::read_symlink
> >>
> >> #ifndef _AIX
> >>@@ -97,11 +100,14 @@ namespace std::chrono
> >> {
> >> namespace
> >> {
> >>-#if ! USE_ATOMIC_SHARED_PTR
> >> #ifndef __GTHREADS
> >> // Dummy no-op mutex type for single-threaded targets.
> >> struct mutex { void lock() { } void unlock() { } };
> >>+#elif ! defined _GLIBCXX_HAS_GHTREADS
> >
> > This still has my GHTREADS typo.
>
> Eh. I had fixed that, but apparently lost it. Re-fixed.
>
> > A comment here would be good too:
> >
> > // Use __gnu_cxx::__mutex is std::mutex isn't available.
>
> Added.
>
> >>+ using mutex = __gnu_cxx::__mutex;
> >> #endif
> >>+
> >>+#if ! USE_ATOMIC_SHARED_PTR
> >> inline mutex& list_mutex()
> >> {
> >> #ifdef __GTHREAD_MUTEX_INIT
> >
> > Strictly speaking, we also need a change here, because unlike
> > std::mutex, __gnu_cxx::__mutex can't be initialized with `constinit`.
> > But that can wait, because it's not needed for your configuration.
>
> I've added an '#error' for such a configuration. (But happy to drop, if
> you think that's overkill.)
That's great, thanks.
No existing targets should be broken by that new #error, because they
would be failing to build already.
>
> Please see v2 of
> "Fix 'libstdc++-v3/src/c++20/tzdb.cc' build for '__GTHREADS && !__GTHREADS_CXX0X' configurations"
> attached. Still only GCN, nvptx build-tested.
OK for trunk if testing goes well.
Is this needed for gcc-14 too?
More information about the Libstdc++
mailing list