public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix build issues with mingw toolchain
@ 2024-05-06  5:58 Bernd Edlinger
  2024-05-06 14:57 ` Tom Tromey
  0 siblings, 1 reply; 25+ messages in thread
From: Bernd Edlinger @ 2024-05-06  5:58 UTC (permalink / raw)
  To: gdb-patches

With a x86_64-pc-mingw32 toolchain there is a build issue
whether or not the --disable-threading option is used.
The problem happens because _WIN32_WINNT is defined to 0x501
before #include <mutex> which makes the compilation abort
due to missing support for __gthread_cond_t in std_mutex.h,
which is conditional on _WIN32_WINNT >= 0x600.

Fix the case when --disable-threading is used, by only
including <mutex> in gdb/complaints.c when STD_CXX_THREAD
is defined.

Additionally make the configure script try to #include <mutex>
to automatically select --disable-threading when the header file
is not able to compile.
---
 gdb/complaints.c     | 2 ++
 gdb/configure        | 1 +
 gdbserver/configure  | 1 +
 gdbsupport/common.m4 | 1 +
 gdbsupport/configure | 1 +
 5 files changed, 6 insertions(+)

diff --git a/gdb/complaints.c b/gdb/complaints.c
index debafde794b..07c0f7e52e5 100644
--- a/gdb/complaints.c
+++ b/gdb/complaints.c
@@ -24,7 +24,9 @@
 #include "top.h"
 #include "gdbsupport/selftest.h"
 #include <unordered_map>
+#if CXX_STD_THREAD
 #include <mutex>
+#endif
 
 /* Map format strings to counters.  */
 
diff --git a/gdb/configure b/gdb/configure
index c3d5cf7ed63..98cd488a737 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -20854,6 +20854,7 @@ else
     # endif
     #endif	/* __MINGW32__ || __CYGWIN__ */
     #include <thread>
+    #include <mutex>
     void callback() { }
 int
 main ()
diff --git a/gdbserver/configure b/gdbserver/configure
index 026d250cc73..2da525ebf3b 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -9561,6 +9561,7 @@ else
     # endif
     #endif	/* __MINGW32__ || __CYGWIN__ */
     #include <thread>
+    #include <mutex>
     void callback() { }
 int
 main ()
diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4
index 240ec008f2a..bef396445ba 100644
--- a/gdbsupport/common.m4
+++ b/gdbsupport/common.m4
@@ -114,6 +114,7 @@ AC_DEFUN([GDB_AC_COMMON], [
     # endif
     #endif	/* __MINGW32__ || __CYGWIN__ */
     #include <thread>
+    #include <mutex>
     void callback() { }]],
   [[std::thread t(callback);]])],
 				gdb_cv_cxx_std_thread=yes,
diff --git a/gdbsupport/configure b/gdbsupport/configure
index ae991250ce4..a218b06ce28 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -12335,6 +12335,7 @@ else
     # endif
     #endif	/* __MINGW32__ || __CYGWIN__ */
     #include <thread>
+    #include <mutex>
     void callback() { }
 int
 main ()
-- 
2.39.2


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2024-05-15  2:20 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-06  5:58 [PATCH] Fix build issues with mingw toolchain Bernd Edlinger
2024-05-06 14:57 ` Tom Tromey
2024-05-06 17:09   ` Bernd Edlinger
2024-05-06 20:18     ` Tom Tromey
2024-05-07 10:59       ` Hannes Domani
2024-05-10 17:24         ` Tom Tromey
2024-05-10 17:32           ` Eli Zaretskii
2024-05-10 17:41           ` Eli Zaretskii
2024-05-10 19:03           ` Pedro Alves
2024-05-11  6:20             ` Eli Zaretskii
2024-05-13 14:21               ` Pedro Alves
2024-05-13 15:36                 ` Eli Zaretskii
2024-05-13 17:12                   ` Pedro Alves
2024-05-13 18:45                 ` Tom Tromey
2024-05-14 14:20                   ` Pedro Alves
2024-05-14 17:02                     ` Eli Zaretskii
2024-05-14 18:47                       ` Pedro Alves
2024-05-14 19:19                         ` Eli Zaretskii
2024-05-11 10:55           ` Hannes Domani
2024-05-13 13:45             ` Tom Tromey
2024-05-10 17:39       ` Eli Zaretskii
2024-05-13 13:48         ` Tom Tromey
2024-05-10 17:37     ` Eli Zaretskii
2024-05-10 19:36       ` Bernd Edlinger
2024-05-11  6:18         ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).