Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Khem Raj <raj.khem@gmail.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 8/8] autoconf: Fix AC_HEADER_MAJOR with glibc 2.25
Date: Sun, 18 Dec 2016 19:06:00 -0800	[thread overview]
Message-ID: <20161219030600.1284-8-raj.khem@gmail.com> (raw)
In-Reply-To: <20161219030600.1284-1-raj.khem@gmail.com>

Backport the patch from master for 2.69

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 .../AC_HEADER_MAJOR-port-to-glibc-2.25.patch       | 147 +++++++++++++++++++++
 meta/recipes-devtools/autoconf/autoconf_2.69.bb    |   1 +
 2 files changed, 148 insertions(+)
 create mode 100644 meta/recipes-devtools/autoconf/autoconf/AC_HEADER_MAJOR-port-to-glibc-2.25.patch

diff --git a/meta/recipes-devtools/autoconf/autoconf/AC_HEADER_MAJOR-port-to-glibc-2.25.patch b/meta/recipes-devtools/autoconf/autoconf/AC_HEADER_MAJOR-port-to-glibc-2.25.patch
new file mode 100644
index 0000000000..8af6c0fdca
--- /dev/null
+++ b/meta/recipes-devtools/autoconf/autoconf/AC_HEADER_MAJOR-port-to-glibc-2.25.patch
@@ -0,0 +1,147 @@
+From e17a30e987d7ee695fb4294a82d987ec3dc9b974 Mon Sep 17 00:00:00 2001
+From: Eric Blake <eblake@redhat.com>
+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 <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.
+
+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.
+* doc/autoconf.texi (Particular Headers) <AC_HEADER_MAJOR>: Expand
+details on usage, and on workarounds for non-updated projects.
+
+Signed-off-by: Eric Blake <eblake@redhat.com>
+---
+Upstream-Status: Backport
+
+ doc/autoconf.texi       |   35 +++++++++++++++++++++++++++++++----
+ lib/autoconf/headers.m4 |   30 ++++++++++++++----------------
+ 2 files changed, 45 insertions(+), 20 deletions(-)
+
+diff --git a/doc/autoconf.texi b/doc/autoconf.texi
+index 9ad7dc1..4f041bd 100644
+--- a/doc/autoconf.texi
++++ b/doc/autoconf.texi
+@@ -5970,10 +5970,37 @@ Also see @code{AC_STRUCT_DIRENT_D_INO} and
+ @cvindex MAJOR_IN_SYSMACROS
+ @hdrindex{sys/mkdev.h}
+ @hdrindex{sys/sysmacros.h}
+-If @file{sys/types.h} does not define @code{major}, @code{minor}, and
+-@code{makedev}, but @file{sys/mkdev.h} does, define
+-@code{MAJOR_IN_MKDEV}; otherwise, if @file{sys/sysmacros.h} does, define
+-@code{MAJOR_IN_SYSMACROS}.
++Detect the headers required to use @code{makedev}, @code{major}, and
++@code{minor}.  These functions may be defined by @file{sys/mkdev.h},
++@code{sys/sysmacros.h}, or @file{sys/types.h}.
++
++@code{AC_HEADER_MAJOR} defines @code{MAJOR_IN_MKDEV} if they are in
++@file{sys/mkdev.h}, or @code{MAJOR_IN_SYSMACROS} if they are in
++@file{sys/sysmacros.h}.  If neither macro is defined, they are either in
++@file{sys/types.h} or unavailable.
++
++To properly use these functions, your code should contain something
++like:
++
++@verbatim
++#include <sys/types.h>
++#ifdef MAJOR_IN_MKDEV
++# include <sys/mkdev.h>
++#elif defined MAJOR_IN_SYSMACROS
++# include <sys/sysmacros.h>
++#endif
++@end verbatim
++
++Note: Configure scripts built with Autoconf 2.69 or earlier will not
++detect a problem if @file{sys/types.h} contains definitions of
++@code{major}, @code{minor}, and/or @code{makedev} that trigger compiler
++warnings upon use.  This is known to occur with GNU libc 2.25, where
++those definitions are being deprecated to reduce namespace pollution.
++If it is not practical to use Autoconf 2.70 to regenerate the configure
++script of affected software, you can work around the problem by setting
++@samp{ac_cv_header_sys_types_h_makedev=no}, as an argument to
++@command{configure} or as part of a @file{config.site} site default file
++(@pxref{Site Defaults}).
+ @end defmac
+ 
+ @defmac AC_HEADER_RESOLV
+diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4
+index 0c44973..72262c1 100644
+--- a/lib/autoconf/headers.m4
++++ b/lib/autoconf/headers.m4
+@@ -427,31 +427,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 <sys/types.h> compiles.
++# If <sys/mkdev.h> compiles, assume it provides major/minor/makedev.
++# Otherwise, if <sys/sysmacros.h> compiles, assume it provides the macros.
++# Otherwise, either the macros were provided by <sys/types.h>, 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 <sys/types.h>]],
+-				 [[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 <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
++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
+ ])# AC_HEADER_MAJOR
+ 
+-- 
+1.7.10.4
+
diff --git a/meta/recipes-devtools/autoconf/autoconf_2.69.bb b/meta/recipes-devtools/autoconf/autoconf_2.69.bb
index aa1877a1fb..fd01585441 100644
--- a/meta/recipes-devtools/autoconf/autoconf_2.69.bb
+++ b/meta/recipes-devtools/autoconf/autoconf_2.69.bb
@@ -14,6 +14,7 @@ SRC_URI += "file://check-automake-cross-warning.patch \
             file://autotest-automake-result-format.patch \
             file://add_musl_config.patch \
             file://performance.patch \
+            file://AC_HEADER_MAJOR-port-to-glibc-2.25.patch \
            "
 
 SRC_URI[md5sum] = "82d05e03b93e45f5a39b828dc9c6c29b"
-- 
2.11.0



      parent reply	other threads:[~2016-12-19  3:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-19  3:05 [PATCH 1/8] webkitgtk: Fix atomic detection on arm architecture Khem Raj
2016-12-19  3:05 ` [PATCH 2/8] gdb: Upgrade to 7.12 Khem Raj
2016-12-19  3:05 ` [PATCH 3/8] grub: Fix build with glibc 2.25 Khem Raj
2016-12-19  3:05 ` [PATCH 4/8] grub-git: Upgrade to tip of master and fix " Khem Raj
2016-12-19  3:05 ` [PATCH 5/8] mdadm: Fix build " Khem Raj
2016-12-19  3:05 ` [PATCH 6/8] pax: " Khem Raj
2016-12-19  3:05 ` [PATCH 7/8] x264: Fix build on mips architectures Khem Raj
2016-12-19 10:30   ` André Draszik
2016-12-19  3:06 ` Khem Raj [this message]

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=20161219030600.1284-8-raj.khem@gmail.com \
    --to=raj.khem@gmail.com \
    --cc=openembedded-core@lists.openembedded.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