public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: GDB 10.1 release -- 2020-09-18 Update
Date: Mon, 21 Sep 2020 19:26:40 +0300	[thread overview]
Message-ID: <83h7rrxfi7.fsf@gnu.org> (raw)
In-Reply-To: <20200919194850.GB5376@adacore.com> (message from Joel Brobecker on Sat, 19 Sep 2020 12:48:50 -0700)

> Date: Sat, 19 Sep 2020 12:48:50 -0700
> From: Joel Brobecker <brobecker@adacore.com>
> Cc: gdb-patches@sourceware.org
> 
> Let's test it first, both in your context, and in a situation
> where the Windows version is more recent, and also with a mingw64
> version of MinGW. Perhaps the way we could do it is if you sent
> the actual GDB patch to install those two gnulib patches into
> our copy after testing on your end that this fixes things, and
> then I could test your patch with newer Windows + MinGW64?

I attach below the patch for our copy of Gnulib on the release
branch.  It works here.  (I will again ask you to kindly regenerate
the configure script(s) that depend on gnulib/import/m4/*.m4 files.)

> There's also the question of updating gnulib on master. I haven't
> heard of anyone who's volunteered for that one... I assume one
> will happen at some point out of someone needing it for other
> reasons, but there is no guarantee this will happen. Do you want
> to take care of doing an update as well?

I've never done this, and would prefer that someone else does that.
Sorry for being such a coward.

Here's the patch for the release branch:

diff --git a/gnulib/ChangeLog b/gnulib/ChangeLog
index bf61742..dfd6d79 100644
--- a/gnulib/ChangeLog
+++ b/gnulib/ChangeLog
@@ -1,3 +1,16 @@
+2020-09-16  Bruno Haible  <bruno@clisp.org>
+
+	stat, fstat: Fix when compiling for versions older than Windows Vista.
+	Reported by Eli Zaretskii <eliz@gnu.org> in
+	<https://lists.gnu.org/archive/html/bug-gnulib/2020-09/msg00027.html>.
+	* import/stat-w32.c: Include <sdkddkver.h>. Test the value of
+	_WIN32_WINNT that was originally set before we redefined it.
+	(VOLUME_NAME_NONE): Define if the Windows headers don't define
+	it.
+	* import/m4/stat.m4 (gl_PREREQ_STAT_W32): New macro.
+	(gl_PREREQ_STAT): Require it.
+	* import/m4/fstat.m4 (gl_PREREQ_FSTAT): Likewise.
+
 2020-09-08  Tom Tromey  <tromey@adacore.com>
 
 	PR win32/25302:
diff --git a/gnulib/import/m4/fstat.m4 b/gnulib/import/m4/fstat.m4
index 53c0896..bd8cb79 100644
--- a/gnulib/import/m4/fstat.m4
+++ b/gnulib/import/m4/fstat.m4
@@ -1,4 +1,4 @@
-# fstat.m4 serial 6
+# fstat.m4 serial 7
 dnl Copyright (C) 2011-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -35,5 +35,6 @@ AC_DEFUN([gl_FUNC_FSTAT],
 # Prerequisites of lib/fstat.c and lib/stat-w32.c.
 AC_DEFUN([gl_PREREQ_FSTAT], [
   AC_REQUIRE([gl_HEADER_SYS_STAT_H])
+  AC_REQUIRE([gl_PREREQ_STAT_W32])
   :
 ])
diff --git a/gnulib/import/m4/stat.m4 b/gnulib/import/m4/stat.m4
index 8ef355f..5e827b5 100644
--- a/gnulib/import/m4/stat.m4
+++ b/gnulib/import/m4/stat.m4
@@ -1,4 +1,4 @@
-# serial 16
+# serial 17
 
 # Copyright (C) 2009-2020 Free Software Foundation, Inc.
 #
@@ -70,5 +70,16 @@ AC_DEFUN([gl_FUNC_STAT],
 # Prerequisites of lib/stat.c and lib/stat-w32.c.
 AC_DEFUN([gl_PREREQ_STAT], [
   AC_REQUIRE([gl_HEADER_SYS_STAT_H])
+  AC_REQUIRE([gl_PREREQ_STAT_W32])
   :
 ])
+
+# Prerequisites of lib/stat-w32.c.
+AC_DEFUN([gl_PREREQ_STAT_W32], [
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  case "$host_os" in
+    mingw*)
+      AC_CHECK_HEADERS([sdkddkver.h])
+      ;;
+  esac
+])
diff --git a/gnulib/import/stat-w32.c b/gnulib/import/stat-w32.c
index 19bdfaa..108ce19 100644
--- a/gnulib/import/stat-w32.c
+++ b/gnulib/import/stat-w32.c
@@ -20,10 +20,22 @@
 
 #if defined _WIN32 && ! defined __CYGWIN__
 
-/* Ensure that <windows.h> defines FILE_ID_INFO.  */
-#if !defined _WIN32_WINNT || (_WIN32_WINNT < _WIN32_WINNT_WIN8)
-# undef _WIN32_WINNT
-# define _WIN32_WINNT _WIN32_WINNT_WIN8
+/* Attempt to make <windows.h> define FILE_ID_INFO.
+   But ensure that the redefinition of _WIN32_WINNT does not make us assume
+   Windows Vista or newer when building for an older version of Windows.  */
+#if HAVE_SDKDDKVER_H
+# include <sdkddkver.h>
+# if _WIN32_WINNT >= _WIN32_WINNT_VISTA
+#  define WIN32_ASSUME_VISTA 1
+# else
+#  define WIN32_ASSUME_VISTA 0
+# endif
+# if !defined _WIN32_WINNT || (_WIN32_WINNT < _WIN32_WINNT_WIN8)
+#  undef _WIN32_WINNT
+#  define _WIN32_WINNT _WIN32_WINNT_WIN8
+# endif
+#else
+# define WIN32_ASSUME_VISTA (_WIN32_WINNT >= _WIN32_WINNT_VISTA)
 #endif
 
 #include <sys/types.h>
@@ -46,7 +58,12 @@
 #undef GetFinalPathNameByHandle
 #define GetFinalPathNameByHandle GetFinalPathNameByHandleA
 
-#if !(_WIN32_WINNT >= _WIN32_WINNT_VISTA)
+/* Older mingw headers do not define VOLUME_NAME_NONE.  */
+#ifndef VOLUME_NAME_NONE
+# define VOLUME_NAME_NONE 4
+#endif
+
+#if !WIN32_ASSUME_VISTA
 
 /* Avoid warnings from gcc -Wcast-function-type.  */
 # define GetProcAddress \
@@ -149,7 +166,7 @@ _gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf)
   DWORD type = GetFileType (h);
   if (type == FILE_TYPE_DISK)
     {
-#if !(_WIN32_WINNT >= _WIN32_WINNT_VISTA)
+#if !WIN32_ASSUME_VISTA
       if (!initialized)
         initialize ();
 #endif

  reply	other threads:[~2020-09-21 16:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-18 23:46 Joel Brobecker
2020-09-19  1:37 ` Simon Marchi
2020-09-19 19:42   ` Joel Brobecker
2020-09-19 23:58     ` Simon Marchi
2020-09-19  7:41 ` Eli Zaretskii
2020-09-19 19:48   ` Joel Brobecker
2020-09-21 16:26     ` Eli Zaretskii [this message]
2020-09-26 17:39       ` Joel Brobecker
2020-09-28  9:30         ` Eli Zaretskii
2020-09-28 20:11           ` Joel Brobecker
2020-10-09 19:53             ` [pushed/gdb-10-branch] gnulib: fix stat/fstat build errors on old Windows version or using old MinGW Joel Brobecker
2020-09-20  1:03 ` GDB 10.1 release -- 2020-09-18 Update Simon Marchi
2020-09-20  6:09   ` Eli Zaretskii
2020-09-21 19:54 ` Simon Marchi
2020-09-23 13:39   ` Tom Tromey
2020-09-23 14:00     ` Simon Marchi

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=83h7rrxfi7.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).