* [PATCH] Default to Vista APIs (0x0600) when _WIN32_WINNT is undefined
@ 2026-11-19 17:56 Nikita.Venkatesh
2026-11-19 20:49 ` Tom Tromey
0 siblings, 1 reply; 6+ messages in thread
From: Nikita.Venkatesh @ 2026-11-19 17:56 UTC (permalink / raw)
To: gdb-patches; +Cc: nd, Nikita Venkatesh
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Default to Vista APIs (0x0600) when _WIN32_WINNT is undefined
2026-11-19 17:56 [PATCH] Default to Vista APIs (0x0600) when _WIN32_WINNT is undefined Nikita.Venkatesh
@ 2026-11-19 20:49 ` Tom Tromey
2026-11-20 7:23 ` Eli Zaretskii
0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2026-11-19 20:49 UTC (permalink / raw)
To: Nikita.Venkatesh; +Cc: gdb-patches, nd
>>>>> Nikita Venkatesh <Nikita.Venkatesh@arm.com> writes:
> 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
Please read:
https://sourceware.org/pipermail/gdb-patches/2021-October/182443.html
That note is the reason the code is this way.
Locally at AdaCore we just patch this to use 0x0602, since we don't need
XP support.
So while I'm sympathetic to your patch, it's hard to see how we would
ever land it.
Supposedly you can get this same effect by configuring with
CXXFLAGS='-D...' but I have not ever tried this.
I feel like we discussed an idea of trying to include the relevant
headers and, if this fails, disable threading. But TBH I don't know if
that's even desirable.
> Default to 0x0600 only when _WIN32_WINNT is undefined. Preserve the
> existing XP minimum for already defined and higher values.
This is a twist on the earlier approach but I'm not sure it's any more
acceptable.
Tom
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Default to Vista APIs (0x0600) when _WIN32_WINNT is undefined
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
0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2026-11-20 7:23 UTC (permalink / raw)
To: Tom Tromey; +Cc: Nikita.Venkatesh, gdb-patches, nd
> From: Tom Tromey <tromey@adacore.com>
> Cc: gdb-patches@sourceware.org, nd@arm.com
> Date: Thu, 19 Nov 2026 13:49:44 -0700
>
> >>>>> Nikita Venkatesh <Nikita.Venkatesh@arm.com> writes:
>
> > 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
>
> Please read:
>
> https://sourceware.org/pipermail/gdb-patches/2021-October/182443.html
>
> That note is the reason the code is this way.
>
> Locally at AdaCore we just patch this to use 0x0602, since we don't need
> XP support.
>
> So while I'm sympathetic to your patch, it's hard to see how we would
> ever land it.
I think we can bump _WIN32_WINNT when GDB is compiled with MinGW64.
That's because MinGW64 dropped XP support quite some time ago, so
MinGW64 cannot be used to build GDB that would work on XP. Building a
GDB which works on XP is only possible using the old mingw.org's
MinGW.
So adding a preprocessor check in that place that MinGW64 is being
used should allow then to bump _WIN32_WINNT. But AFAIR it's a bit
tricky to find a preprocessor macro that will reliably tell that
MinGW64 is being used, because the header files which define such
macros are not guaranteed to be included. I used to use something
like
#include <_mingw.h>
#if defined __MINGW64_VERSION_MAJOR
/* we are using MinGW64 */
I hope it still works with today's MinGW64.
> I feel like we discussed an idea of trying to include the relevant
> headers and, if this fails, disable threading. But TBH I don't know if
> that's even desirable.
If standard C++ threads are not supported by the compiler and the
library, threading in GDB is automatically disabled at configure time.
> > Default to 0x0600 only when _WIN32_WINNT is undefined. Preserve the
> > existing XP minimum for already defined and higher values.
>
> This is a twist on the earlier approach but I'm not sure it's any more
> acceptable.
Yes, relying on _WIN32_WINNT to be undefined is not a good idea,
because the system headers usually define it to some default value.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] Default to Vista APIs for MinGW-w64 when no version is selected
2026-11-20 7:23 ` Eli Zaretskii
@ 2026-11-25 16:48 ` Nikita.Venkatesh
2026-11-25 17:36 ` Eli Zaretskii
0 siblings, 1 reply; 6+ messages in thread
From: Nikita.Venkatesh @ 2026-11-25 16:48 UTC (permalink / raw)
To: gdb-patches; +Cc: eliz, tromey, nd, Nikita Venkatesh
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.
Detect MinGW-w64 during configure by including <_mingw.h> and checking
for MINGW64_VERSION_MAJOR. Record the result in GDB_USING_MINGW_W64.
Use this result in common-defs.h and the configure threading test
to default to 0x0600 for MinGW-w64 when _WIN32_WINNT is undefined.
Keep the 0x0501 default for other configurations and preserve the
existing handling of explicitly defined values.
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.
Verified that full MinGW GCC 13 builds succeed with both automatic
threading detection and explicit --enable-threading.
---
Changes in v2:
- Detect MinGW-w64 during configure.
- Default to Vista APIs only for MinGW-w64 when _WIN32_WINNT
is undefined, retaining the XP default otherwise.
OK for trunk?
gdb/config.in | 3 +++
gdb/configure | 56 ++++++++++++++++++++++++++++++++++++++++
gdbserver/config.in | 3 +++
gdbserver/configure | 56 ++++++++++++++++++++++++++++++++++++++++
gdbsupport/common-defs.h | 11 +++++---
gdbsupport/common.m4 | 25 ++++++++++++++++++
gdbsupport/config.in | 3 +++
gdbsupport/configure | 56 ++++++++++++++++++++++++++++++++++++++++
8 files changed, 210 insertions(+), 3 deletions(-)
diff --git a/gdb/config.in b/gdb/config.in
index 2e42440d4cc..785cea67216 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -86,6 +86,9 @@
/* Define if self-testing features should be enabled */
#undef GDB_SELF_TEST
+/* Define to 1 when building with MinGW-w64 headers. */
+#undef GDB_USING_MINGW_W64
+
/* Define to 1 if you have `alloca', as a function or macro. */
#undef HAVE_ALLOCA
diff --git a/gdb/configure b/gdb/configure
index e747ffce49f..ed63ed4a7bc 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -20463,6 +20463,60 @@ fi
done
+ # Identify MinGW-w64 before selecting the Windows API version.
+ case ${host} in
+ *mingw*)
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the host uses MinGW-w64" >&5
+$as_echo_n "checking whether the host uses MinGW-w64... " >&6; }
+if ${gdb_cv_mingw_w64+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #include <_mingw.h>
+ #ifndef __MINGW64_VERSION_MAJOR
+ # error Not MinGW-w64
+ #endif
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ gdb_cv_mingw_w64=yes
+else
+ gdb_cv_mingw_w64=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_mingw_w64" >&5
+$as_echo "$gdb_cv_mingw_w64" >&6; }
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+ if test "$gdb_cv_mingw_w64" = yes; then
+
+$as_echo "#define GDB_USING_MINGW_W64 1" >>confdefs.h
+
+ fi
+ ;;
+ esac
+
# ----------------------- #
# Check for threading. #
# ----------------------- #
@@ -21167,6 +21221,8 @@ else
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
# endif
+ # elif defined (GDB_USING_MINGW_W64)
+ # define _WIN32_WINNT 0x0600
# else
# define _WIN32_WINNT 0x0501
# endif
diff --git a/gdbserver/config.in b/gdbserver/config.in
index cf6ebe0a4f2..35ba8e499fc 100644
--- a/gdbserver/config.in
+++ b/gdbserver/config.in
@@ -18,6 +18,9 @@
/* Define if self-testing features should be enabled */
#undef GDB_SELF_TEST
+/* Define to 1 when building with MinGW-w64 headers. */
+#undef GDB_USING_MINGW_W64
+
/* Define to 1 if you have `alloca', as a function or macro. */
#undef HAVE_ALLOCA
diff --git a/gdbserver/configure b/gdbserver/configure
index e00e1e1c1c5..27fd19f9338 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -8658,6 +8658,60 @@ fi
done
+ # Identify MinGW-w64 before selecting the Windows API version.
+ case ${host} in
+ *mingw*)
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the host uses MinGW-w64" >&5
+$as_echo_n "checking whether the host uses MinGW-w64... " >&6; }
+if ${gdb_cv_mingw_w64+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #include <_mingw.h>
+ #ifndef __MINGW64_VERSION_MAJOR
+ # error Not MinGW-w64
+ #endif
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ gdb_cv_mingw_w64=yes
+else
+ gdb_cv_mingw_w64=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_mingw_w64" >&5
+$as_echo "$gdb_cv_mingw_w64" >&6; }
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+ if test "$gdb_cv_mingw_w64" = yes; then
+
+$as_echo "#define GDB_USING_MINGW_W64 1" >>confdefs.h
+
+ fi
+ ;;
+ esac
+
# ----------------------- #
# Check for threading. #
# ----------------------- #
@@ -9362,6 +9416,8 @@ else
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
# endif
+ # elif defined (GDB_USING_MINGW_W64)
+ # define _WIN32_WINNT 0x0600
# else
# define _WIN32_WINNT 0x0501
# endif
diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h
index 1c0ae0ad9d1..41c21d8e985 100644
--- a/gdbsupport/common-defs.h
+++ b/gdbsupport/common-defs.h
@@ -83,9 +83,12 @@
#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 Vista (0x600) APIs for
+ MinGW-w64 and XP (0x501) APIs otherwise. GCC's native Win32
+ C++11 threading support requires Vista APIs.
NOTE: this must be kept in sync with common.m4. */
#if defined (__MINGW32__) || defined (__CYGWIN__)
@@ -94,6 +97,8 @@
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
# endif
+# elif defined (GDB_USING_MINGW_W64)
+# define _WIN32_WINNT 0x0600
# else
# define _WIN32_WINNT 0x0501
# endif
diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4
index bf21c31d78d..40566d13994 100644
--- a/gdbsupport/common.m4
+++ b/gdbsupport/common.m4
@@ -99,6 +99,29 @@ AC_CHECK_HEADERS([ \
# Define HAVE_KINFO_GETFILE if kinfo_getfile is available.
AC_CHECK_FUNCS(kinfo_getfile)
+ # Identify MinGW-w64 before selecting the Windows API version.
+ case ${host} in
+ *mingw*)
+ AC_LANG_PUSH([C++])
+ AC_CACHE_CHECK([whether the host uses MinGW-w64],
+ [gdb_cv_mingw_w64],
+ [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ #include <_mingw.h>
+ #ifndef __MINGW64_VERSION_MAJOR
+ # error Not MinGW-w64
+ #endif
+ ]], [[]])],
+ [gdb_cv_mingw_w64=yes],
+ [gdb_cv_mingw_w64=no])])
+ AC_LANG_POP([C++])
+
+ if test "$gdb_cv_mingw_w64" = yes; then
+ AC_DEFINE([GDB_USING_MINGW_W64], [1],
+ [Define to 1 when building with MinGW-w64 headers.])
+ fi
+ ;;
+ esac
+
# ----------------------- #
# Check for threading. #
# ----------------------- #
@@ -131,6 +154,8 @@ AC_CHECK_HEADERS([ \
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
# endif
+ # elif defined (GDB_USING_MINGW_W64)
+ # define _WIN32_WINNT 0x0600
# else
# define _WIN32_WINNT 0x0501
# endif
diff --git a/gdbsupport/config.in b/gdbsupport/config.in
index ff84ab0d600..4d368e60045 100644
--- a/gdbsupport/config.in
+++ b/gdbsupport/config.in
@@ -21,6 +21,9 @@
/* Define if self-testing features should be enabled */
#undef GDB_SELF_TEST
+/* Define to 1 when building with MinGW-w64 headers. */
+#undef GDB_USING_MINGW_W64
+
/* Define to 1 if you have `alloca', as a function or macro. */
#undef HAVE_ALLOCA
diff --git a/gdbsupport/configure b/gdbsupport/configure
index 7ed4e259ffe..4f0577b9929 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -11559,6 +11559,60 @@ fi
done
+ # Identify MinGW-w64 before selecting the Windows API version.
+ case ${host} in
+ *mingw*)
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the host uses MinGW-w64" >&5
+$as_echo_n "checking whether the host uses MinGW-w64... " >&6; }
+if ${gdb_cv_mingw_w64+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #include <_mingw.h>
+ #ifndef __MINGW64_VERSION_MAJOR
+ # error Not MinGW-w64
+ #endif
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ gdb_cv_mingw_w64=yes
+else
+ gdb_cv_mingw_w64=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_mingw_w64" >&5
+$as_echo "$gdb_cv_mingw_w64" >&6; }
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+ if test "$gdb_cv_mingw_w64" = yes; then
+
+$as_echo "#define GDB_USING_MINGW_W64 1" >>confdefs.h
+
+ fi
+ ;;
+ esac
+
# ----------------------- #
# Check for threading. #
# ----------------------- #
@@ -12263,6 +12317,8 @@ else
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
# endif
+ # elif defined (GDB_USING_MINGW_W64)
+ # define _WIN32_WINNT 0x0600
# else
# define _WIN32_WINNT 0x0501
# endif
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] Default to Vista APIs for MinGW-w64 when no version is selected
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
0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2026-11-25 17:36 UTC (permalink / raw)
To: Nikita.Venkatesh; +Cc: gdb-patches, tromey, nd
> From: Nikita.Venkatesh@arm.com
> Cc: eliz@gnu.org,
> tromey@adacore.com,
> nd@arm.com,
> Nikita Venkatesh <Nikita.Venkatesh@arm.com>
> Date: Wed, 25 Nov 2026 16:48:51 +0000
>
> 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.
>
> Detect MinGW-w64 during configure by including <_mingw.h> and checking
> for MINGW64_VERSION_MAJOR. Record the result in GDB_USING_MINGW_W64.
>
> Use this result in common-defs.h and the configure threading test
> to default to 0x0600 for MinGW-w64 when _WIN32_WINNT is undefined.
> Keep the 0x0501 default for other configurations and preserve the
> existing handling of explicitly defined values.
>
> 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.
>
> Verified that full MinGW GCC 13 builds succeed with both automatic
> threading detection and explicit --enable-threading.
> ---
>
> Changes in v2:
> - Detect MinGW-w64 during configure.
> - Default to Vista APIs only for MinGW-w64 when _WIN32_WINNT
> is undefined, retaining the XP default otherwise.
>
> OK for trunk?
>
> gdb/config.in | 3 +++
> gdb/configure | 56 ++++++++++++++++++++++++++++++++++++++++
> gdbserver/config.in | 3 +++
> gdbserver/configure | 56 ++++++++++++++++++++++++++++++++++++++++
> gdbsupport/common-defs.h | 11 +++++---
> gdbsupport/common.m4 | 25 ++++++++++++++++++
> gdbsupport/config.in | 3 +++
> gdbsupport/configure | 56 ++++++++++++++++++++++++++++++++++++++++
> 8 files changed, 210 insertions(+), 3 deletions(-)
Thanks.
> diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h
> index 1c0ae0ad9d1..41c21d8e985 100644
> --- a/gdbsupport/common-defs.h
> +++ b/gdbsupport/common-defs.h
> @@ -83,9 +83,12 @@
> #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 Vista (0x600) APIs for
> + MinGW-w64 and XP (0x501) APIs otherwise. GCC's native Win32
> + C++11 threading support requires Vista APIs.
>
> NOTE: this must be kept in sync with common.m4. */
> #if defined (__MINGW32__) || defined (__CYGWIN__)
> @@ -94,6 +97,8 @@
> # undef _WIN32_WINNT
> # define _WIN32_WINNT 0x0501
> # endif
> +# elif defined (GDB_USING_MINGW_W64)
> +# define _WIN32_WINNT 0x0600
> # else
> # define _WIN32_WINNT 0x0501
> # endif
AFAIU, you want to define _WIN32_WINNT to 0x0600 even if it _is_
defined, but to a lower value, no? If so, I think the branch where
_WIN32_WINNT is defined but to a smaller value also needs to be
adjusted, right? The conditions look now like this:
#if defined (__MINGW32__) || defined (__CYGWIN__)
# ifdef _WIN32_WINNT
# if _WIN32_WINNT < 0x0501
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
# endif
# else
# define _WIN32_WINNT 0x0501
# endif
#endif /* __MINGW32__ || __CYGWIN__ */
I think when GDB_USING_MINGW_W64 is defined, you want 0x0600 as the
minimal value, not 0x0501. Or am I missing something?
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3] Default to Vista APIs for MinGW-w64 when no version is selected
2026-11-25 17:36 ` Eli Zaretskii
@ 2026-11-26 16:53 ` Nikita.Venkatesh
0 siblings, 0 replies; 6+ messages in thread
From: Nikita.Venkatesh @ 2026-11-26 16:53 UTC (permalink / raw)
To: gdb-patches; +Cc: eliz, tromey, nd, Nikita Venkatesh
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.
Detect MinGW-w64 during configure by including <_mingw.h> and checking
for MINGW64_VERSION_MAJOR. Record the result in GDB_USING_MINGW_W64.
Use this result in common-defs.h and the configure threading test
to require atleast 0x0600 for MinGW-w64, including when
_WIN32_WINNT is already defined to a lower value. Preserve higher
values and retain the existing XP minimum for other configurations.
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.
Verified that full MinGW GCC 13 builds succeed with both automatic
threading detection and explicit --enable-threading.
---
Thanks, Eli. MinGW-w64 builds now raise _WIN32_WINNT to 0x0600
even when a lower value is already defined. Higher values are preserved.
gdb/config.in | 3 ++
gdb/configure | 61 +++++++++++++++++++++++++++++++++++++++-
gdbserver/config.in | 3 ++
gdbserver/configure | 61 +++++++++++++++++++++++++++++++++++++++-
gdbsupport/common-defs.h | 14 ++++++---
gdbsupport/common.m4 | 30 +++++++++++++++++++-
gdbsupport/config.in | 3 ++
gdbsupport/configure | 61 +++++++++++++++++++++++++++++++++++++++-
8 files changed, 228 insertions(+), 8 deletions(-)
diff --git a/gdb/config.in b/gdb/config.in
index 2e42440d4cc..785cea67216 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -86,6 +86,9 @@
/* Define if self-testing features should be enabled */
#undef GDB_SELF_TEST
+/* Define to 1 when building with MinGW-w64 headers. */
+#undef GDB_USING_MINGW_W64
+
/* Define to 1 if you have `alloca', as a function or macro. */
#undef HAVE_ALLOCA
diff --git a/gdb/configure b/gdb/configure
index e747ffce49f..933c056b257 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -20463,6 +20463,60 @@ fi
done
+ # Identify MinGW-w64 before selecting the Windows API version.
+ case ${host} in
+ *mingw*)
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the host uses MinGW-w64" >&5
+$as_echo_n "checking whether the host uses MinGW-w64... " >&6; }
+if ${gdb_cv_mingw_w64+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #include <_mingw.h>
+ #ifndef __MINGW64_VERSION_MAJOR
+ # error Not MinGW-w64
+ #endif
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ gdb_cv_mingw_w64=yes
+else
+ gdb_cv_mingw_w64=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_mingw_w64" >&5
+$as_echo "$gdb_cv_mingw_w64" >&6; }
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+ if test "$gdb_cv_mingw_w64" = yes; then
+
+$as_echo "#define GDB_USING_MINGW_W64 1" >>confdefs.h
+
+ fi
+ ;;
+ esac
+
# ----------------------- #
# Check for threading. #
# ----------------------- #
@@ -21163,10 +21217,15 @@ else
/* end confdefs.h. */
#if defined (__MINGW32__) || defined (__CYGWIN__)
# ifdef _WIN32_WINNT
- # if _WIN32_WINNT < 0x0501
+ # if defined (GDB_USING_MINGW_W64) && _WIN32_WINNT < 0x0600
+ # undef _WIN32_WINNT
+ # define _WIN32_WINNT 0x0600
+ # elif _WIN32_WINNT < 0x0501
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
# endif
+ # elif defined (GDB_USING_MINGW_W64)
+ # define _WIN32_WINNT 0x0600
# else
# define _WIN32_WINNT 0x0501
# endif
diff --git a/gdbserver/config.in b/gdbserver/config.in
index cf6ebe0a4f2..35ba8e499fc 100644
--- a/gdbserver/config.in
+++ b/gdbserver/config.in
@@ -18,6 +18,9 @@
/* Define if self-testing features should be enabled */
#undef GDB_SELF_TEST
+/* Define to 1 when building with MinGW-w64 headers. */
+#undef GDB_USING_MINGW_W64
+
/* Define to 1 if you have `alloca', as a function or macro. */
#undef HAVE_ALLOCA
diff --git a/gdbserver/configure b/gdbserver/configure
index e00e1e1c1c5..04787824299 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -8658,6 +8658,60 @@ fi
done
+ # Identify MinGW-w64 before selecting the Windows API version.
+ case ${host} in
+ *mingw*)
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the host uses MinGW-w64" >&5
+$as_echo_n "checking whether the host uses MinGW-w64... " >&6; }
+if ${gdb_cv_mingw_w64+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #include <_mingw.h>
+ #ifndef __MINGW64_VERSION_MAJOR
+ # error Not MinGW-w64
+ #endif
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ gdb_cv_mingw_w64=yes
+else
+ gdb_cv_mingw_w64=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_mingw_w64" >&5
+$as_echo "$gdb_cv_mingw_w64" >&6; }
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+ if test "$gdb_cv_mingw_w64" = yes; then
+
+$as_echo "#define GDB_USING_MINGW_W64 1" >>confdefs.h
+
+ fi
+ ;;
+ esac
+
# ----------------------- #
# Check for threading. #
# ----------------------- #
@@ -9358,10 +9412,15 @@ else
/* end confdefs.h. */
#if defined (__MINGW32__) || defined (__CYGWIN__)
# ifdef _WIN32_WINNT
- # if _WIN32_WINNT < 0x0501
+ # if defined (GDB_USING_MINGW_W64) && _WIN32_WINNT < 0x0600
+ # undef _WIN32_WINNT
+ # define _WIN32_WINNT 0x0600
+ # elif _WIN32_WINNT < 0x0501
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
# endif
+ # elif defined (GDB_USING_MINGW_W64)
+ # define _WIN32_WINNT 0x0600
# else
# define _WIN32_WINNT 0x0501
# endif
diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h
index 1c0ae0ad9d1..5ca77009a45 100644
--- a/gdbsupport/common-defs.h
+++ b/gdbsupport/common-defs.h
@@ -83,17 +83,23 @@
#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.
+/* Require at least Windows Vista APIs for MinGW-w64, because GCC's
+ native Win32 C++11 threading support requires them. For other
+ configurations, require at least Windows XP APIs. Preserve
+ higher values selected by the build.
NOTE: this must be kept in sync with common.m4. */
#if defined (__MINGW32__) || defined (__CYGWIN__)
# ifdef _WIN32_WINNT
-# if _WIN32_WINNT < 0x0501
+# if defined (GDB_USING_MINGW_W64) && _WIN32_WINNT < 0x0600
+# undef _WIN32_WINNT
+# define _WIN32_WINNT 0x0600
+# elif _WIN32_WINNT < 0x0501
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
# endif
+# elif defined (GDB_USING_MINGW_W64)
+# define _WIN32_WINNT 0x0600
# else
# define _WIN32_WINNT 0x0501
# endif
diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4
index bf21c31d78d..5042375d3e1 100644
--- a/gdbsupport/common.m4
+++ b/gdbsupport/common.m4
@@ -99,6 +99,29 @@ AC_CHECK_HEADERS([ \
# Define HAVE_KINFO_GETFILE if kinfo_getfile is available.
AC_CHECK_FUNCS(kinfo_getfile)
+ # Identify MinGW-w64 before selecting the Windows API version.
+ case ${host} in
+ *mingw*)
+ AC_LANG_PUSH([C++])
+ AC_CACHE_CHECK([whether the host uses MinGW-w64],
+ [gdb_cv_mingw_w64],
+ [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ #include <_mingw.h>
+ #ifndef __MINGW64_VERSION_MAJOR
+ # error Not MinGW-w64
+ #endif
+ ]], [[]])],
+ [gdb_cv_mingw_w64=yes],
+ [gdb_cv_mingw_w64=no])])
+ AC_LANG_POP([C++])
+
+ if test "$gdb_cv_mingw_w64" = yes; then
+ AC_DEFINE([GDB_USING_MINGW_W64], [1],
+ [Define to 1 when building with MinGW-w64 headers.])
+ fi
+ ;;
+ esac
+
# ----------------------- #
# Check for threading. #
# ----------------------- #
@@ -127,10 +150,15 @@ AC_CHECK_HEADERS([ \
dnl NOTE: this must be kept in sync with common-defs.h.
[[#if defined (__MINGW32__) || defined (__CYGWIN__)
# ifdef _WIN32_WINNT
- # if _WIN32_WINNT < 0x0501
+ # if defined (GDB_USING_MINGW_W64) && _WIN32_WINNT < 0x0600
+ # undef _WIN32_WINNT
+ # define _WIN32_WINNT 0x0600
+ # elif _WIN32_WINNT < 0x0501
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
# endif
+ # elif defined (GDB_USING_MINGW_W64)
+ # define _WIN32_WINNT 0x0600
# else
# define _WIN32_WINNT 0x0501
# endif
diff --git a/gdbsupport/config.in b/gdbsupport/config.in
index ff84ab0d600..4d368e60045 100644
--- a/gdbsupport/config.in
+++ b/gdbsupport/config.in
@@ -21,6 +21,9 @@
/* Define if self-testing features should be enabled */
#undef GDB_SELF_TEST
+/* Define to 1 when building with MinGW-w64 headers. */
+#undef GDB_USING_MINGW_W64
+
/* Define to 1 if you have `alloca', as a function or macro. */
#undef HAVE_ALLOCA
diff --git a/gdbsupport/configure b/gdbsupport/configure
index 7ed4e259ffe..44aa19b4a48 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -11559,6 +11559,60 @@ fi
done
+ # Identify MinGW-w64 before selecting the Windows API version.
+ case ${host} in
+ *mingw*)
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the host uses MinGW-w64" >&5
+$as_echo_n "checking whether the host uses MinGW-w64... " >&6; }
+if ${gdb_cv_mingw_w64+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #include <_mingw.h>
+ #ifndef __MINGW64_VERSION_MAJOR
+ # error Not MinGW-w64
+ #endif
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ gdb_cv_mingw_w64=yes
+else
+ gdb_cv_mingw_w64=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_mingw_w64" >&5
+$as_echo "$gdb_cv_mingw_w64" >&6; }
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+ if test "$gdb_cv_mingw_w64" = yes; then
+
+$as_echo "#define GDB_USING_MINGW_W64 1" >>confdefs.h
+
+ fi
+ ;;
+ esac
+
# ----------------------- #
# Check for threading. #
# ----------------------- #
@@ -12259,10 +12313,15 @@ else
/* end confdefs.h. */
#if defined (__MINGW32__) || defined (__CYGWIN__)
# ifdef _WIN32_WINNT
- # if _WIN32_WINNT < 0x0501
+ # if defined (GDB_USING_MINGW_W64) && _WIN32_WINNT < 0x0600
+ # undef _WIN32_WINNT
+ # define _WIN32_WINNT 0x0600
+ # elif _WIN32_WINNT < 0x0501
# undef _WIN32_WINNT
# define _WIN32_WINNT 0x0501
# endif
+ # elif defined (GDB_USING_MINGW_W64)
+ # define _WIN32_WINNT 0x0600
# else
# define _WIN32_WINNT 0x0501
# endif
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-26 16:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 17:56 [PATCH] Default to Vista APIs (0x0600) when _WIN32_WINNT is undefined Nikita.Venkatesh
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox