[gnulib PATCH 0/2] Work around glibc 2.25 deprecation warnings

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[gnulib PATCH 0/2] Work around glibc 2.25 deprecation warnings

Eric Blake-3
Fedora rawhide builds of libvirt.git at commit d53fa838^ failed
due to the new glibc 2.25 deprecation warning for use of major()
from just <sys/types.h>; I also found that the same warning is
provoked by gnulib's mountlist module.  Libvirt commit d53fa838
was a temporary hack to work around the problem, and I will be
reverting that and updating to newer gnulib once this goes in.

I've tested that libvirt on Fedora rawhide with d53fa838 reverted
and gnulib updated to this commit was once again able to build.

Comments welcome, particularly for my choice of wording in
documentation changes.  The final push will differ slightly from
this, especially if the autoconf patch going in first changes
slightly due to review there, but this should give a good idea
of the fix.

Eric Blake (2):
  mountlist: include sysmacros.h for glibc
  sys_types: avoid glibc 2.25 warnings about major()

 ChangeLog                                | 15 +++++++++++++++
 doc/glibc-functions/gnu_dev_major.texi   |  4 ++++
 doc/glibc-functions/gnu_dev_makedev.texi |  4 ++++
 doc/glibc-functions/gnu_dev_minor.texi   |  4 ++++
 doc/posix-headers/sys_types.texi         |  6 ++++++
 lib/mountlist.c                          |  6 ++++++
 m4/mountlist.m4                          |  3 ++-
 m4/sys_types_h.m4                        | 27 ++++++++++++++++++++++++++-
 8 files changed, 67 insertions(+), 2 deletions(-)

--
2.7.4


_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 2/2] sys_types: avoid glibc 2.25 warnings about major()

Eric Blake-3
Todo: tweak sys_types_h.m4 comment before pushing

glibc 2.25 is deprecating the namespace pollution of <sys/types.h>
injecting major(), minor(), and makedev() into the compilation
environment, with a warning that insists that users include
<sys/sysmacros.h> instead.  However, because the expansion of
AC_HEADER_MAJOR didn't bother checking sys/sysmacros.h until
after probing whether sys/types.h pollutes the namespace, it was
not defining MAJOR_IN_SYSMACROS, with the result that code
compiled with -Werror chokes on the deprecation warnings because
it was not including sysmacros.h.

Backport the autoconf fix, so that gnulib projects avoid the
warnings even when using older autoconf.

* m4/sys_types_h.m4 (AC_HEADER_MAJOR): Replace broken version in
older autoconf.
* doc/posix-headers/sys_types.texi (sys/types.h): Document fix.
* doc/glibc-functions/gnu_dev_major.texi (gnu_dev_major): Likewise.
* doc/glibc-functions/gnu_dev_makedev.texi (gnu_dev_makedev): Likewise.
* doc/glibc-functions/gnu_dev_minor.texi (gnu_dev_minor): Likewise.

Signed-off-by: Eric Blake <[hidden email]>
---

Obviously, I'll be tweaking this slightly to list an actual
commit id that gets pushed to autoconf, but posting now for
review.

 ChangeLog                                |  8 ++++++++
 doc/glibc-functions/gnu_dev_major.texi   |  4 ++++
 doc/glibc-functions/gnu_dev_makedev.texi |  4 ++++
 doc/glibc-functions/gnu_dev_minor.texi   |  4 ++++
 doc/posix-headers/sys_types.texi         |  6 ++++++
 m4/sys_types_h.m4                        | 27 ++++++++++++++++++++++++++-
 6 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index ae0816d..1e694e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2016-09-14  Eric Blake  <[hidden email]>

+ sys_types: avoid glibc 2.25 warnings about major()
+ * m4/sys_types_h.m4 (AC_HEADER_MAJOR): Replace broken version in
+ older autoconf.
+ * doc/posix-headers/sys_types.texi (sys/types.h): Document fix.
+ * doc/glibc-functions/gnu_dev_major.texi (gnu_dev_major): Likewise.
+ * doc/glibc-functions/gnu_dev_makedev.texi (gnu_dev_makedev): Likewise.
+ * doc/glibc-functions/gnu_dev_minor.texi (gnu_dev_minor): Likewise.
+
  mountlist: include sysmacros.h for glibc
  * m4/mountlist.m4 (gl_PREREQ_MOUTLIST_EXTRA): Include
  AC_HEADER_MAJOR.
diff --git a/doc/glibc-functions/gnu_dev_major.texi b/doc/glibc-functions/gnu_dev_major.texi
index f7a2cfd..3a85300 100644
--- a/doc/glibc-functions/gnu_dev_major.texi
+++ b/doc/glibc-functions/gnu_dev_major.texi
@@ -6,6 +6,10 @@ gnu_dev_major

 Portability problems fixed by Gnulib:
 @itemize
+The @code{AC_HEADER_MAJOR} macro in Autoconf 2.69 and earlier fails to
+set @code{MAJOR_IN_SYSMACROS} when it detects namespace pollution in
+@file{sys/types.h}; which in turn provokes deprecation warnings in
+glibc 2.25.
 @end itemize

 Portability problems not fixed by Gnulib:
diff --git a/doc/glibc-functions/gnu_dev_makedev.texi b/doc/glibc-functions/gnu_dev_makedev.texi
index febd7f8..2738698 100644
--- a/doc/glibc-functions/gnu_dev_makedev.texi
+++ b/doc/glibc-functions/gnu_dev_makedev.texi
@@ -6,6 +6,10 @@ gnu_dev_makedev

 Portability problems fixed by Gnulib:
 @itemize
+The @code{AC_HEADER_MAJOR} macro in Autoconf 2.69 and earlier fails to
+set @code{MAJOR_IN_SYSMACROS} when it detects namespace pollution in
+@file{sys/types.h}; which in turn provokes deprecation warnings in
+glibc 2.25.
 @end itemize

 Portability problems not fixed by Gnulib:
diff --git a/doc/glibc-functions/gnu_dev_minor.texi b/doc/glibc-functions/gnu_dev_minor.texi
index a3dbefe..b4c789c 100644
--- a/doc/glibc-functions/gnu_dev_minor.texi
+++ b/doc/glibc-functions/gnu_dev_minor.texi
@@ -6,6 +6,10 @@ gnu_dev_minor

 Portability problems fixed by Gnulib:
 @itemize
+The @code{AC_HEADER_MAJOR} macro in Autoconf 2.69 and earlier fails to
+set @code{MAJOR_IN_SYSMACROS} when it detects namespace pollution in
+@file{sys/types.h}; which in turn provokes deprecation warnings in
+glibc 2.25.
 @end itemize

 Portability problems not fixed by Gnulib:
diff --git a/doc/posix-headers/sys_types.texi b/doc/posix-headers/sys_types.texi
index 29bb9ae..cf44bea 100644
--- a/doc/posix-headers/sys_types.texi
+++ b/doc/posix-headers/sys_types.texi
@@ -19,6 +19,12 @@ sys/types.h
 @item
 The type @code{mode_t} is not defined on some platforms:
 MSVC 9.
+@item
+Some systems leak definitions of @code{major}, @code{minor}, and
+@code{makedev} through this header; however, when
+@file{sys/sysmacros.h} exists, that file should also be included to
+avoid deprecation warnings from the versions in this header:
+glibc 2.25.
 @end itemize

 Portability problems not fixed by Gnulib:
diff --git a/m4/sys_types_h.m4 b/m4/sys_types_h.m4
index b0aabb4..64be679 100644
--- a/m4/sys_types_h.m4
+++ b/m4/sys_types_h.m4
@@ -1,4 +1,4 @@
-# sys_types_h.m4 serial 5
+# sys_types_h.m4 serial 6
 dnl Copyright (C) 2011-2016 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -22,3 +22,28 @@ AC_DEFUN_ONCE([gl_SYS_TYPES_H],
 AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS],
 [
 ])
+
+# This works around a buggy version in autoconf <= 2.69.
+# See <https://lists.gnu.org/archive/html/autoconf/2016-08/msg00014.html>
+
+m4_version_prereq([2.70], [], [
+
+# This is taken from the following Autoconf patch:
+# http://git.sv.gnu.org/cgit/autoconf.git/commit/?id=XXXXXXX
+
+m4_undefine([AC_HEADER_MAJOR])
+AC_DEFUN([AC_HEADER_MAJOR],
+[AC_CHECK_HEADERS_ONCE([sys/types.h])
+AC_CHECK_HEADER([sys/mkdev.h],
+  [AC_DEFINE([MAJOR_IN_MKDEV], [1],
+    [Define to 1 if `major', `minor', and `makedev' are declared in
+     <mkdev.h>.])])
+if test $ac_cv_header_sys_mkdev_h = no; then
+  AC_CHECK_HEADER([sys/sysmacros.h],
+    [AC_DEFINE([MAJOR_IN_SYSMACROS], [1],
+      [Define to 1 if `major', `minor', and `makedev' are declared in
+       <sysmacros.h>.])])
+fi
+])
+
+])
--
2.7.4


_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 1/2] mountlist: include sysmacros.h for glibc

Eric Blake-3
In reply to this post by Eric Blake-3
On Fedora rawhide (glibc 2.25), './gnulib-tool --test mountlist'
reports:
../../gllib/mountlist.c: In function 'read_file_system_list':
../../gllib/mountlist.c:534:13: warning: '__makedev_from_sys_types' is deprecated:
  In the GNU C Library, `makedev' is defined by <sys/sysmacros.h>.
  For historical compatibility, it is currently defined by
  <sys/types.h> as well, but we plan to remove this soon.
  To use `makedev', include <sys/sysmacros.h> directly.
  If you did not intend to use a system-defined macro `makedev',
  you should #undef it after including <sys/types.h>.
  [-Wdeprecated-declarations]
             me->me_dev = makedev (devmaj, devmin);
             ^~
In file included from /usr/include/features.h:397:0,
                 from /usr/include/sys/types.h:25,
                 from ./sys/types.h:28,
                 from ../../gllib/mountlist.h:23,
                 from ../../gllib/mountlist.c:20:
/usr/include/sys/sysmacros.h:89:1: note: declared here
 __SYSMACROS_DEFINE_MAKEDEV (__SYSMACROS_FST_IMPL_TEMPL)
 ^

Fix it by including the right headers.  We also need a fix to
autoconf's AC_HEADER_MAJOR, but that's a separate patch.

* m4/mountlist.m4 (gl_PREREQ_MOUTLIST_EXTRA): Include
AC_HEADER_MAJOR.
* lib/mountlist.c (includes): Use correct headers.

Signed-off-by: Eric Blake <[hidden email]>
---
 ChangeLog       | 7 +++++++
 lib/mountlist.c | 6 ++++++
 m4/mountlist.m4 | 3 ++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index a936166..ae0816d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2016-09-14  Eric Blake  <[hidden email]>
+
+ mountlist: include sysmacros.h for glibc
+ * m4/mountlist.m4 (gl_PREREQ_MOUTLIST_EXTRA): Include
+ AC_HEADER_MAJOR.
+ * lib/mountlist.c (includes): Use correct headers.
+
 2016-09-13  Paul Eggert  <[hidden email]>

  intprops: new macro TYPE_WIDTH
diff --git a/lib/mountlist.c b/lib/mountlist.c
index bb4e4ee..cf4020e 100644
--- a/lib/mountlist.c
+++ b/lib/mountlist.c
@@ -37,6 +37,12 @@
 # include <sys/param.h>
 #endif

+#if MAJOR_IN_MKDEV
+# include <sys/mkdev.h>
+#elif MAJOR_IN_SYSMACROS
+# include <sys/sysmacros.h>
+#endif
+
 #if defined MOUNTED_GETFSSTAT   /* OSF_1 and Darwin1.3.x */
 # if HAVE_SYS_UCRED_H
 #  include <grp.h> /* needed on OSF V4.0 for definition of NGROUPS,
diff --git a/m4/mountlist.m4 b/m4/mountlist.m4
index 2e2ca37..b6724fa 100644
--- a/m4/mountlist.m4
+++ b/m4/mountlist.m4
@@ -1,4 +1,4 @@
-# serial 11
+# serial 12
 dnl Copyright (C) 2002-2006, 2009-2016 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -15,5 +15,6 @@ AC_DEFUN([gl_PREREQ_MOUNTLIST_EXTRA],
 [
   dnl Note gl_LIST_MOUNTED_FILE_SYSTEMS checks for mntent.h, not sys/mntent.h.
   AC_CHECK_HEADERS([sys/mntent.h])
+  AC_HEADER_MAJOR()dnl for use of makedev ()
   gl_FSTYPENAME
 ])
--
2.7.4


_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Loading...