From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id L4bgDDBkCGu0kwAAWB0awg (envelope-from ) for ; Thu, 26 Nov 2026 11:54:08 -0500 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=QxJsKwST; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 08D621E166; Thu, 26 Nov 2026 11:54:08 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C0FDC1E09B for ; Thu, 26 Nov 2026 11:54:05 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 78D364368149 for ; Thu, 26 Nov 2026 16:54:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 78D364368149 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=QxJsKwST Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id C21194380CDD for ; Thu, 26 Nov 2026 16:53:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C21194380CDD Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C21194380CDD Authentication-Results: sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795712012; cv=none; b=DqbiBE6RTBhY+RmXE1S0n/G8cCdDc8p1UXWmv0Ki3dVgJijhaxoVbwGOfmQ1O5bjQZm3pjcmzyERMwFzyKEblZY9EXr2/W2+Y8MaBsglbK4HgwnjlrF4NAPkcUMCI6aHywGj9GoL3SEtBI9q3wTxFykLPCHqa1da8zgt2vAdBx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795712012; c=relaxed/simple; bh=8AeC5/4WzjXj0sdrT/TcrjOVh9XAHgDQwF0dd5CCIrk=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Kvk+AdmF+M0OpV6a62NxKYPRkdARqgCOmx5YwtR+suQrMB7MiUfDZnjh7+DFipEZqyXwqteIt5g34PhEvmW1Bh5kQPfkbcLQVkh54QY8arFCskWwTvb0ecrXeglH3mFW6NJvzub7JrADnY2JnxZ69zo5/zCso80YhXY5Ih11P2o= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=QxJsKwST DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C21194380CDD Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C16851BA8; Thu, 26 Nov 2026 08:53:27 -0800 (PST) Received: from e129758.cambridge.arm.com (e129758.arm.com [10.2.212.12]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BD28C3F86F; Thu, 26 Nov 2026 08:53:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1795712010; bh=8AeC5/4WzjXj0sdrT/TcrjOVh9XAHgDQwF0dd5CCIrk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QxJsKwSTR6IJpypHGqTusz3sUGFQT21qgZJoh7Y6mdFyrQQTvLL/+3uZQ7vQLNJA3 nPRVX0ylil2/8wgTORZjIQxTgDID+Ahu8xdvjaw0uwIM8HptW3Ai2OvSK5B427k+jo orffbP1J3eGRgg86uy3Ol253hBhir3dwx+QDj4Ow= From: Nikita.Venkatesh@arm.com To: gdb-patches@sourceware.org Cc: eliz@gnu.org, tromey@adacore.com, nd@arm.com, Nikita Venkatesh Subject: [PATCH v3] Default to Vista APIs for MinGW-w64 when no version is selected Date: Thu, 26 Nov 2026 16:53:00 +0000 Message-Id: <20261126165300.624595-1-Nikita.Venkatesh@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <861p88ertv.fsf@gnu.org> References: <861p88ertv.fsf@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org From: Nikita Venkatesh 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 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