[gcc r16-9547] libstdc++: Fix grep for linker warning about --gc-sections [PR126452]

Jonathan Wakely via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <20260818150245.346B04BA23E7__11424.6376020432$1787065375$gmane$org@sourceware.org>
https://gcc.gnu.org/g:7f84e9af923261f3fdd7f15b064c449b7d4157b9

commit r16-9547-g7f84e9af923261f3fdd7f15b064c449b7d4157b9
Author: Jonathan Wakely <[email protected]>
Date:   Wed Jul 29 16:55:39 2026 +0100

    libstdc++: Fix grep for linker warning about --gc-sections [PR126452]
    
    Current versions of GNU ld print "warning" with a lowercase 'w' so
    adjust the grep patter. Also use LC_ALL=C to ensure the warning isn't
    translated.
    
    Because m4 uses square brackets as quotes, we need to use double
    brackets in the grep pattern to expand to "[Ww]" in the configure
    script.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/126452
            * acinclude.m4 (GLIBCXX_CHECK_LINKER_FEATURES): Use LC_ALL_C and
            match both "Warning" and "warning" in ld output.
            * configure: Regenerate.
    
    Reviewed-by: Jakub Jelinek <[email protected]>
    (cherry picked from commit b7ce998a967639b955159eeeae940cb069c518d8)

Diff:
---
 libstdc++-v3/acinclude.m4 |  4 ++--
 libstdc++-v3/configure    | 36 ++++++++++++++++++------------------
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index a615692e7beb..e8c913d9cb59 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -261,8 +261,8 @@ AC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [
       rm -f conftest.c
       touch conftest.c
       if $CC -c conftest.c; then
-	if $LD --gc-sections -o conftest conftest.o 2>&1 | \
-	   grep "Warning: gc-sections option ignored" > /dev/null; then
+	if LC_ALL=C $LD --gc-sections -o conftest conftest.o 2>&1 | \
+	   grep "[[Ww]]arning: gc-sections option ignored" > /dev/null; then
 	  ac_gcsections=no
 	fi
       fi
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index bc9dce5e2880..5a8d4ae09921 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -23198,8 +23198,8 @@ rm -f core conftest.err conftest.$ac_objext \
       rm -f conftest.c
       touch conftest.c
       if $CC -c conftest.c; then
-	if $LD --gc-sections -o conftest conftest.o 2>&1 | \
-	   grep "Warning: gc-sections option ignored" > /dev/null; then
+	if LC_ALL=C $LD --gc-sections -o conftest conftest.o 2>&1 | \
+	   grep "[Ww]arning: gc-sections option ignored" > /dev/null; then
 	  ac_gcsections=no
 	fi
       fi
@@ -29199,8 +29199,8 @@ rm -f core conftest.err conftest.$ac_objext \
       rm -f conftest.c
       touch conftest.c
       if $CC -c conftest.c; then
-	if $LD --gc-sections -o conftest conftest.o 2>&1 | \
-	   grep "Warning: gc-sections option ignored" > /dev/null; then
+	if LC_ALL=C $LD --gc-sections -o conftest conftest.o 2>&1 | \
+	   grep "[Ww]arning: gc-sections option ignored" > /dev/null; then
 	  ac_gcsections=no
 	fi
       fi
@@ -32381,8 +32381,8 @@ rm -f core conftest.err conftest.$ac_objext \
       rm -f conftest.c
       touch conftest.c
       if $CC -c conftest.c; then
-	if $LD --gc-sections -o conftest conftest.o 2>&1 | \
-	   grep "Warning: gc-sections option ignored" > /dev/null; then
+	if LC_ALL=C $LD --gc-sections -o conftest conftest.o 2>&1 | \
+	   grep "[Ww]arning: gc-sections option ignored" > /dev/null; then
 	  ac_gcsections=no
 	fi
       fi
@@ -38602,8 +38602,8 @@ rm -f core conftest.err conftest.$ac_objext \
       rm -f conftest.c
       touch conftest.c
       if $CC -c conftest.c; then
-	if $LD --gc-sections -o conftest conftest.o 2>&1 | \
-	   grep "Warning: gc-sections option ignored" > /dev/null; then
+	if LC_ALL=C $LD --gc-sections -o conftest conftest.o 2>&1 | \
+	   grep "[Ww]arning: gc-sections option ignored" > /dev/null; then
 	  ac_gcsections=no
 	fi
       fi
@@ -38893,8 +38893,8 @@ rm -f core conftest.err conftest.$ac_objext \
       rm -f conftest.c
       touch conftest.c
       if $CC -c conftest.c; then
-	if $LD --gc-sections -o conftest conftest.o 2>&1 | \
-	   grep "Warning: gc-sections option ignored" > /dev/null; then
+	if LC_ALL=C $LD --gc-sections -o conftest conftest.o 2>&1 | \
+	   grep "[Ww]arning: gc-sections option ignored" > /dev/null; then
 	  ac_gcsections=no
 	fi
       fi
@@ -39361,8 +39361,8 @@ rm -f core conftest.err conftest.$ac_objext \
       rm -f conftest.c
       touch conftest.c
       if $CC -c conftest.c; then
-	if $LD --gc-sections -o conftest conftest.o 2>&1 | \
-	   grep "Warning: gc-sections option ignored" > /dev/null; then
+	if LC_ALL=C $LD --gc-sections -o conftest conftest.o 2>&1 | \
+	   grep "[Ww]arning: gc-sections option ignored" > /dev/null; then
 	  ac_gcsections=no
 	fi
       fi
@@ -42806,8 +42806,8 @@ rm -f core conftest.err conftest.$ac_objext \
       rm -f conftest.c
       touch conftest.c
       if $CC -c conftest.c; then
-	if $LD --gc-sections -o conftest conftest.o 2>&1 | \
-	   grep "Warning: gc-sections option ignored" > /dev/null; then
+	if LC_ALL=C $LD --gc-sections -o conftest conftest.o 2>&1 | \
+	   grep "[Ww]arning: gc-sections option ignored" > /dev/null; then
 	  ac_gcsections=no
 	fi
       fi
@@ -46204,8 +46204,8 @@ rm -f core conftest.err conftest.$ac_objext \
       rm -f conftest.c
       touch conftest.c
       if $CC -c conftest.c; then
-	if $LD --gc-sections -o conftest conftest.o 2>&1 | \
-	   grep "Warning: gc-sections option ignored" > /dev/null; then
+	if LC_ALL=C $LD --gc-sections -o conftest conftest.o 2>&1 | \
+	   grep "[Ww]arning: gc-sections option ignored" > /dev/null; then
 	  ac_gcsections=no
 	fi
       fi
@@ -46420,8 +46420,8 @@ rm -f core conftest.err conftest.$ac_objext \
       rm -f conftest.c
       touch conftest.c
       if $CC -c conftest.c; then
-	if $LD --gc-sections -o conftest conftest.o 2>&1 | \
-	   grep "Warning: gc-sections option ignored" > /dev/null; then
+	if LC_ALL=C $LD --gc-sections -o conftest conftest.o 2>&1 | \
+	   grep "[Ww]arning: gc-sections option ignored" > /dev/null; then
 	  ac_gcsections=no
 	fi
       fi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.