From: Eli Zaretskii <eliz@gnu.org>
To: Nikita.Venkatesh@arm.com
Cc: gdb-patches@sourceware.org, tromey@adacore.com, nd@arm.com
Subject: Re: [PATCH v2] Default to Vista APIs for MinGW-w64 when no version is selected
Date: Wed, 25 Nov 2026 19:36:28 +0200 [thread overview]
Message-ID: <861p88ertv.fsf@gnu.org> (raw)
In-Reply-To: <20261125164851.416291-1-Nikita.Venkatesh@arm.com>
> 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>
next prev parent reply other threads:[~2026-11-25 17:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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=861p88ertv.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=Nikita.Venkatesh@arm.com \
--cc=gdb-patches@sourceware.org \
--cc=nd@arm.com \
--cc=tromey@adacore.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