Make copy of <bits/std_abs.h> from GCC 7 [BZ #21573]

Message ID CAMe9rOqAf23yuz7U-7P2NfJuX5j74wdbVfncpnXMyp2-ZHYrXg@mail.gmail.com
State New, archived
Headers

Commit Message

H.J. Lu Sept. 7, 2017, 5:26 p.m. UTC
  On Tue, Jun 13, 2017 at 1:21 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Jun 13, 2017 at 1:13 PM, Florian Weimer <fweimer@redhat.com> wrote:
>> On 06/13/2017 01:54 PM, H.J. Lu wrote:
>>> -    echo "#include <$1>" | $CXX -M -MP -x c++ - | sed -n "/$1:/{s/:\$//;p}"
>>> +    echo "#include <$1>" | $CXX -M -MP -x c++ - | sed -n "\,$1:,{s/:\$//;p}"
>>>    }
>>>    CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
>>> +  # Also make a copy of <bits/std_abs.h> from GCC 7 to prevent it from
>>> +  # including /usr/include/stdlib.h.
>>> +  CXX_CSTDLIB_HEADER="$CXX_CSTDLIB_HEADER $(find_cxx_header bits/std_abs.h)"
>>
>> I think the attached patch is needed to suppress the error message if
>> the header does not exist.  (Regenerated configure file not shown in the
>> patch.)
>>
>
> LGTM.
>

Here is a patch to backport these 2 patches to 2.25 branch.   Any
comments?
  

Comments

H.J. Lu Sept. 11, 2017, 3:53 p.m. UTC | #1
On Thu, Sep 7, 2017 at 10:26 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Jun 13, 2017 at 1:21 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Tue, Jun 13, 2017 at 1:13 PM, Florian Weimer <fweimer@redhat.com> wrote:
>>> On 06/13/2017 01:54 PM, H.J. Lu wrote:
>>>> -    echo "#include <$1>" | $CXX -M -MP -x c++ - | sed -n "/$1:/{s/:\$//;p}"
>>>> +    echo "#include <$1>" | $CXX -M -MP -x c++ - | sed -n "\,$1:,{s/:\$//;p}"
>>>>    }
>>>>    CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
>>>> +  # Also make a copy of <bits/std_abs.h> from GCC 7 to prevent it from
>>>> +  # including /usr/include/stdlib.h.
>>>> +  CXX_CSTDLIB_HEADER="$CXX_CSTDLIB_HEADER $(find_cxx_header bits/std_abs.h)"
>>>
>>> I think the attached patch is needed to suppress the error message if
>>> the header does not exist.  (Regenerated configure file not shown in the
>>> patch.)
>>>
>>
>> LGTM.
>>
>
> Here is a patch to backport these 2 patches to 2.25 branch.   Any
> comments?
>

I am checking it into 2.25 branch.
  

Patch

From a746c011f8b6bb7ffae39258d7e3b24e8b5cde40 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Tue, 13 Jun 2017 09:28:14 -0700
Subject: [PATCH] Make copy of <bits/std_abs.h> from GCC 7 [BZ #21573]

<bits/std_abs.h> from GCC 7 will include /usr/include/stdlib.h from
"#include_next" (instead of stdlib/stdlib.h in the glibc source
directory), and this turns up as a make dependency.  Also make a copy
of <bits/std_abs.h> to prevent it from including /usr/include/stdlib.h.

	* configure.ac (find_cxx_header): Suppress compiler error message.
	* configure: Regenerated.

	[BZ #21573]
	* Makerules [$(c++-bits-std_abs-h) != ""] (before-compile): Add
	$(common-objpfx)bits/std_abs.h.
	[$(c++-bits-std_abs-h) != ""] ($(common-objpfx)bits/std_abs.h):
	New target.
	* config.make.in (c++-bits-std_abs-h): New.
	* configure.ac (find_cxx_header): Use "\,$1," with sed.
	(CXX_BITS_STD_ABS_H): New.
	(AC_SUBST(CXX_BITS_STD_ABS_H)): Likewise.
	* configure: Regenerated.

(cherry picked from commit a65ea28d1833d3502c5070472e43bda04410e6b5 and
 commit c2528fef3b05bcffb1ac27c6c09cc3ff24b7f03f)
---
 Makerules      | 8 ++++++++
 config.make.in | 1 +
 configure      | 6 +++++-
 configure.ac   | 5 ++++-
 4 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/Makerules b/Makerules
index 7403305d30..43343f03ee 100644
--- a/Makerules
+++ b/Makerules
@@ -127,6 +127,14 @@  $(common-objpfx)cstdlib: $(c++-cstdlib-header)
 $(common-objpfx)cmath: $(c++-cmath-header)
 	$(INSTALL_DATA) $< $@T
 	$(move-if-change) $@T $@
+ifneq (,$(c++-bits-std_abs-h))
+# Also make a copy of <bits/std_abs.h> from GCC 7 to prevent it from
+# including /usr/include/stdlib.h.
+before-compile := $(common-objpfx)bits/std_abs.h $(before-compile)
+$(common-objpfx)bits/std_abs.h: $(c++-bits-std_abs-h)
+	$(INSTALL_DATA) $< $@T
+	$(move-if-change) $@T $@
+endif
 endif
 
 before-compile := $(common-objpfx)libc-abis.h $(before-compile)
diff --git a/config.make.in b/config.make.in
index 5836b32a72..709527da4f 100644
--- a/config.make.in
+++ b/config.make.in
@@ -47,6 +47,7 @@  sysincludes = @SYSINCLUDES@
 c++-sysincludes = @CXX_SYSINCLUDES@
 c++-cstdlib-header = @CXX_CSTDLIB_HEADER@
 c++-cmath-header = @CXX_CMATH_HEADER@
+c++-bits-std_abs-h = @CXX_BITS_STD_ABS_H@
 all-warnings = @all_warnings@
 enable-werror = @enable_werror@
 
diff --git a/configure b/configure
index eecd0ace74..ee637a7caf 100755
--- a/configure
+++ b/configure
@@ -634,6 +634,7 @@  BISON
 INSTALL_INFO
 PERL
 BASH_SHELL
+CXX_BITS_STD_ABS_H
 CXX_CMATH_HEADER
 CXX_CSTDLIB_HEADER
 CXX_SYSINCLUDES
@@ -5318,14 +5319,17 @@  fi
 # copy of those headers in Makerules.
 if test -n "$CXX"; then
   find_cxx_header () {
-    echo "#include <$1>" | $CXX -M -MP -x c++ - | sed -n "/$1:/{s/:\$//;p}"
+    echo "#include <$1>" | $CXX -M -MP -x c++ - 2>/dev/null \
+	 | sed -n "\,$1:,{s/:\$//;p}"
   }
   CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
   CXX_CMATH_HEADER="$(find_cxx_header cmath)"
+  CXX_BITS_STD_ABS_H="$(find_cxx_header bits/std_abs.h)"
 fi
 
 
 
+
 # Test if LD_LIBRARY_PATH contains the notation for the current directory
 # since this would lead to problems installing/building glibc.
 # LD_LIBRARY_PATH contains the current directory if one of the following
diff --git a/configure.ac b/configure.ac
index 4a77411b71..d288ff43cd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1176,13 +1176,16 @@  AC_SUBST(CXX_SYSINCLUDES)
 # copy of those headers in Makerules.
 if test -n "$CXX"; then
   find_cxx_header () {
-    echo "#include <$1>" | $CXX -M -MP -x c++ - | sed -n "/$1:/{s/:\$//;p}"
+    echo "#include <$1>" | $CXX -M -MP -x c++ - 2>/dev/null \
+	 | sed -n "\,$1:,{s/:\$//;p}"
   }
   CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
   CXX_CMATH_HEADER="$(find_cxx_header cmath)"
+  CXX_BITS_STD_ABS_H="$(find_cxx_header bits/std_abs.h)"
 fi
 AC_SUBST(CXX_CSTDLIB_HEADER)
 AC_SUBST(CXX_CMATH_HEADER)
+AC_SUBST(CXX_BITS_STD_ABS_H)
 
 # Test if LD_LIBRARY_PATH contains the notation for the current directory
 # since this would lead to problems installing/building glibc.
-- 
2.13.5