]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Set _WIN32_WINNT in common.m4 configure check
authorTom Tromey <tromey@adacore.com>
Mon, 9 Jan 2023 14:43:29 +0000 (07:43 -0700)
committerTom Tromey <tromey@adacore.com>
Thu, 12 Jan 2023 14:20:46 +0000 (07:20 -0700)
GCC recently added support for the Windows thread model, enabling
libstdc++ to support Windows natively.  However, this supporrt
requires a version of Windows later than the minimum version that is
supported by GDB.

PR build/29966 points out that the GDB configure test for std::thread
does not work in this situation, because _WIN32_WINNT is not defined
in test program, and so <thread> seems to be fine.

This patch is an attempt to fix the problem, by using the same setting
for _WIN32_WINNT at configure time as is used at build time.

I don't have access to one of the older systems so I don't think I can
truly test this.  I did do a mingw cross build, though.  I'm going to
ask the bug reporter to test it.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29966

(cherry picked from commit 2124b2de4bba05063218501dcccfc4cffe648cda)

gdb/configure
gdbserver/configure
gdbsupport/common-defs.h
gdbsupport/common.m4
gdbsupport/configure

index 23e6b7160ecd91d76bab43ecdb961a0e1167828c..bdea17043b55f2eb49bd5274e22eacae565f4f8d 100755 (executable)
@@ -25967,7 +25967,17 @@ if ${gdb_cv_cxx_std_thread+:} false; then :
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include <thread>
+  #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__ */
+    #include <thread>
     void callback() { }
 int
 main ()
index 050264ed7dad2fe049bda7f8627472d4bf3f1b7c..6dc6b1ff6ad97f229bda7683b928ab24c5b271ac 100755 (executable)
@@ -7941,7 +7941,17 @@ if ${gdb_cv_cxx_std_thread+:} false; then :
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include <thread>
+  #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__ */
+    #include <thread>
     void callback() { }
 int
 main ()
index bcebd7187d9318d1d830a743e06c8c701e20ad72..5e529f6febf6e2124ceab190223368b9cb40931c 100644 (file)
@@ -70,7 +70,9 @@
 
 /* We don't support Windows versions before XP, so we define
    _WIN32_WINNT correspondingly to ensure the Windows API headers
-   expose the required symbols.  */
+   expose the required symbols.
+
+   NOTE: this must be kept in sync with common.m4.  */
 #if defined (__MINGW32__) || defined (__CYGWIN__)
 # ifdef _WIN32_WINNT
 #  if _WIN32_WINNT < 0x0501
index 7b100262c296505e6c0ad754ab55deaddc516137..b3aa27185ea3a79a19a67ba4d7743f9693cf9335 100644 (file)
@@ -100,7 +100,18 @@ AC_DEFUN([GDB_AC_COMMON], [
   AC_CACHE_CHECK([for std::thread],
                 gdb_cv_cxx_std_thread,
                 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
-  [[#include <thread>
+  dnl NOTE: this must be kept in sync with common-defs.h.
+  [[#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__ */
+    #include <thread>
     void callback() { }]],
   [[std::thread t(callback);]])],
                                gdb_cv_cxx_std_thread=yes,
index 38541e87c15d615f90b87c89161c7c8f20895f0b..44dd8a9f70417ac186a5449ea5d6d613f342a6f5 100755 (executable)
@@ -8957,7 +8957,17 @@ if ${gdb_cv_cxx_std_thread+:} false; then :
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include <thread>
+  #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__ */
+    #include <thread>
     void callback() { }
 int
 main ()