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

Jonathan Wakely via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <20260818185500.9F4E44BA79AA__23004.3931327359$1787079326$gmane$org@sourceware.org>
https://gcc.gnu.org/g:83876d9d6b3249376f80c8c7d6156a912dc8dea0

commit r15-11483-g83876d9d6b3249376f80c8c7d6156a912dc8dea0
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 a0094c2dd95b..7d31f9692435 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -253,8 +253,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 527548051d53..8a4cd513baa7 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -23015,8 +23015,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
@@ -28882,8 +28882,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
@@ -32061,8 +32061,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
@@ -38279,8 +38279,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
@@ -38567,8 +38567,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
@@ -39032,8 +39032,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
@@ -42474,8 +42474,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
@@ -45869,8 +45869,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
@@ -46082,8 +46082,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.