Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Nikita.Venkatesh@arm.com
To: gdb-patches@sourceware.org
Cc: nd@arm.com, Nikita Venkatesh <Nikita.Venkatesh@arm.com>
Subject: [PATCH] Default to Vista APIs (0x0600) when _WIN32_WINNT is undefined
Date: Thu, 19 Nov 2026 17:56:05 +0000	[thread overview]
Message-ID: <20261119175605.3837218-1-Nikita.Venkatesh@arm.com> (raw)

From: Nikita Venkatesh <Nikita.Venkatesh@arm.com>

GCC13 added win32 C++11 threading support that requires
Windows Vista (0x0600) condition variable APIs. GDB's
XP default hides the required declarations, causing
GDB compilation to fail.

With --enable-threading, configure stops with an error. With automatic
detection, configure disables GDB threading, but compilation later
fails because other libstdc++ headers still require those declarations.

The following discussions were considered:
https://sourceware.org/pipermail/gdb/2022-November/050448.html
https://sourceware.org/pipermail/gdb-patches/2024-May/209176.html

Including <sdkddkver.h> as suggested in the 2024 discussion,
does not resolve this with Ubuntu 24.04's mingw-w64 headers.
It instead defaults to 0x0502, which is below the required
0x0600.

Default to 0x0600 only when _WIN32_WINNT is undefined. Preserve the
existing XP minimum for already defined and higher values. An
explicitly selected XP target is preserved. However, builds using
GCC's native Win32 C++11 threading support require Vista or later.

Verified that full MinGW GCC 13 builds succeed with both automatic
threading detection and explicit --enable-threading.
---
 gdb/configure            |  2 +-
 gdbserver/configure      |  2 +-
 gdbsupport/common-defs.h | 10 ++++++----
 gdbsupport/common.m4     |  2 +-
 gdbsupport/configure     |  2 +-
 5 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/gdb/configure b/gdb/configure
index e747ffce49f..39cbc817657 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -21168,7 +21168,7 @@ else
     #   define _WIN32_WINNT 0x0501
     #  endif
     # else
-    #  define _WIN32_WINNT 0x0501
+    #  define _WIN32_WINNT 0x0600
     # endif
     #endif	/* __MINGW32__ || __CYGWIN__ */
     #include <thread>
diff --git a/gdbserver/configure b/gdbserver/configure
index e00e1e1c1c5..cebef407494 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -9363,7 +9363,7 @@ else
     #   define _WIN32_WINNT 0x0501
     #  endif
     # else
-    #  define _WIN32_WINNT 0x0501
+    #  define _WIN32_WINNT 0x0600
     # endif
     #endif	/* __MINGW32__ || __CYGWIN__ */
     #include <thread>
diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h
index 1c0ae0ad9d1..38e1d3402e4 100644
--- a/gdbsupport/common-defs.h
+++ b/gdbsupport/common-defs.h
@@ -83,9 +83,11 @@
 #define _FORTIFY_SOURCE 2
 #endif
 
-/* We don't support Windows versions before XP, so we define
-   _WIN32_WINNT correspondingly to ensure the Windows API headers
-   expose the required symbols.
+/* We don't support Windows versions before XP, so ensure that
+   _WIN32_WINNT is atleast 0x0501 when already defined.
+
+   If it is undefined, default to 0x0600 because GCC's native
+   win32 C++11 threading support requires Windows Vista APIs.
 
    NOTE: this must be kept in sync with common.m4.  */
 #if defined (__MINGW32__) || defined (__CYGWIN__)
@@ -95,7 +97,7 @@
 #   define _WIN32_WINNT 0x0501
 #  endif
 # else
-#  define _WIN32_WINNT 0x0501
+#  define _WIN32_WINNT 0x0600
 # endif
 #endif	/* __MINGW32__ || __CYGWIN__ */
 
diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4
index bf21c31d78d..4ee949d0be4 100644
--- a/gdbsupport/common.m4
+++ b/gdbsupport/common.m4
@@ -132,7 +132,7 @@ AC_CHECK_HEADERS([ \
     #   define _WIN32_WINNT 0x0501
     #  endif
     # else
-    #  define _WIN32_WINNT 0x0501
+    #  define _WIN32_WINNT 0x0600
     # endif
     #endif	/* __MINGW32__ || __CYGWIN__ */
     #include <thread>
diff --git a/gdbsupport/configure b/gdbsupport/configure
index 7ed4e259ffe..74e4551e4a8 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -12264,7 +12264,7 @@ else
     #   define _WIN32_WINNT 0x0501
     #  endif
     # else
-    #  define _WIN32_WINNT 0x0501
+    #  define _WIN32_WINNT 0x0600
     # endif
     #endif	/* __MINGW32__ || __CYGWIN__ */
     #include <thread>
-- 
2.34.1


             reply	other threads:[~2026-11-19 17:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 17:56 Nikita.Venkatesh [this message]
2026-11-19 20:49 ` Tom Tromey
2026-11-20  7:23   ` Eli Zaretskii
2026-11-25 16:48     ` [PATCH v2] Default to Vista APIs for MinGW-w64 when no version is selected Nikita.Venkatesh
2026-11-25 17:36       ` Eli Zaretskii
2026-11-26 16:53         ` [PATCH v3] " Nikita.Venkatesh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261119175605.3837218-1-Nikita.Venkatesh@arm.com \
    --to=nikita.venkatesh@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=nd@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox