From b859ab1b211d348b46eca9158b7742f050c8115e Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 14 Sep 2016 08:17:06 -0500 Subject: [PATCH] AC_HEADER_MAJOR: port to glibc 2.25 glibc 2.25 is deprecating the namespace pollution of injecting major(), minor(), and makedev() into the compilation environment, with a warning that insists that users include 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. In addition to fixing autoconf (which only benefits projects that rebuild configure after this fix is released), we can also give a hint to distros on how they can populate config.site with a cache variable to force pre-existing configure scripts without the updated macro to behave sanely in the presence of glibc 2.25 (the documentation is especially useful since that cache variable is no longer present in autoconf after this patch). Note that mingw lacks major/minor/makedev in any of its standard headers; for that platform, the behavior of this macro is unchanged (code using the recommended include formula will get a compile error when trying to use major(), whether before or after this patch); but for now, it is assumed that programs actually concerned with creating devices are not worried about portability to mingw. If desired, a later patch could tighten AC_HEADER_MAJOR to fail at configure time if the macros are unavailable in any of the three system headers, but that semantic change is not worth mixing into this patch. * lib/autoconf/headers.m4 (AC_HEADER_MAJOR): Drop check for major within sys/types.h; it interferes with the need to check sysmacros.h first. Signed-off-by: Eric Blake Remove the documentation change from the patch Upstream-Status: Backport Signed-off-by: Hongxu Jia --- lib/autoconf/headers.m4 | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4 index 81a7fa2..a57d0d3 100644 --- a/lib/autoconf/headers.m4 +++ b/lib/autoconf/headers.m4 @@ -502,31 +502,29 @@ fi # AC_HEADER_MAJOR # --------------- +# Thanks to glibc 2.25 deprecating macros in sys/types.h, coupled with +# back-compat to autoconf 2.69, we need the following logic: +# Check whether compiles. +# If compiles, assume it provides major/minor/makedev. +# Otherwise, if compiles, assume it provides the macros. +# Otherwise, either the macros were provided by , or do +# not exist on the platform. Code trying to use these three macros is +# assumed to not care about platforms that lack the macros. AN_FUNCTION([major], [AC_HEADER_MAJOR]) AN_FUNCTION([makedev], [AC_HEADER_MAJOR]) AN_FUNCTION([minor], [AC_HEADER_MAJOR]) AN_HEADER([sys/mkdev.h], [AC_HEADER_MAJOR]) AC_DEFUN([AC_HEADER_MAJOR], -[AC_CACHE_CHECK(whether sys/types.h defines makedev, - ac_cv_header_sys_types_h_makedev, -[AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include ]], - [[return makedev(0, 0);]])], - [ac_cv_header_sys_types_h_makedev=yes], - [ac_cv_header_sys_types_h_makedev=no]) -]) - -if test $ac_cv_header_sys_types_h_makedev = no; then +[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 .])]) - - 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 .])]) - fi +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 .])]) fi ])# AC_HEADER_MAJOR -- 2.7.4