[gcc r15-2944] libstdc++-v3: testsuite: Prune uncapitalized "in function" linker warning

2024-08-15 Thread Hans-Peter Nilsson via Libstdc++-cvs
https://gcc.gnu.org/g:98e1b19f6690f5e19031ba4f843c22208bbfb14a

commit r15-2944-g98e1b19f6690f5e19031ba4f843c22208bbfb14a
Author: Hans-Peter Nilsson 
Date:   Wed Aug 14 04:38:05 2024 +0200

libstdc++-v3: testsuite: Prune uncapitalized "in function" linker warning

Newer newlib trigger warnings about certain functions not implemented
(_getentropy) when testing libstdc++-v3.

Since 2018 (circa binutils-2.31) the "in function" prefix isn't
capitalized for those "not implemented" warnings when generated from
the linker (a GNU ld feature used by newlib).  Dejagnu up to and
including at least dejagnu-1.6.3 (and git @ 42979bd3b9) assumes a
capital "In function", leaving that part unpruned, and boom we have
thousands of "excess errors" from the libstdc++-v3 testsuite.

While gcc/testsuite/lib/prune.exp:prune_gcc_output already deals with
this quirk with a vastly more generic pattern, I choose this simpler
tweak.

libstdc++-v3:
* testsuite/lib/prune.exp (libstdc++-dg-prune): Prune
uncapitalized "in function" warning from linker.

Diff:
---
 libstdc++-v3/testsuite/lib/prune.exp | 9 +
 1 file changed, 9 insertions(+)

diff --git a/libstdc++-v3/testsuite/lib/prune.exp 
b/libstdc++-v3/testsuite/lib/prune.exp
index 071dcf34c1e..4250e2d39e7 100644
--- a/libstdc++-v3/testsuite/lib/prune.exp
+++ b/libstdc++-v3/testsuite/lib/prune.exp
@@ -80,6 +80,15 @@ proc libstdc++-dg-prune { system text } {
 # Ignore dsymutil warning (tool bug is actually in the linker)
 regsub -all "(^|\n)\[^\n\]*could not find object file symbol for 
symbol\[^\n\]*" $text "" text
 
+# This pattern, except requiring a capitalized "In" and with a
+# sub-pattern matching a subsequent line "is not implemented and will
+# always fail", is part of the standard dejagnu prune_warnings function.
+# There's also a separate single-line pattern pruning the "is not
+# implemented and will always fail".  Since that pattern is processed
+# before this ${tool}-dg-prune function is called, we have to handle
+# the single uncapitalized "in function" line.
+regsub -all "(^|\n)\[^\n\]*: in function\[^\n\]*" $text "" text
+
 # If exceptions are disabled, mark tests expecting exceptions to be enabled
 # as unsupported.
 if { ![check_effective_target_exceptions_enabled] } {


[gcc r15-2945] libstdc++-v3: Handle iconv as optional for newlib builds [PR116362]

2024-08-15 Thread Hans-Peter Nilsson via Libstdc++-cvs
https://gcc.gnu.org/g:1b8b53ef75c143cddc114705c97c74d9c8f7a64b

commit r15-2945-g1b8b53ef75c143cddc114705c97c74d9c8f7a64b
Author: Hans-Peter Nilsson 
Date:   Tue Aug 13 19:23:43 2024 +0200

libstdc++-v3: Handle iconv as optional for newlib builds [PR116362]

Support for iconv in newlib seems to have been always
assumed present by libstdc++-v3, but is default off.

Though, it hasn't been used before recent libstdc++ changes
that actually call iconv functions.  This now leads to
failures exposed by running the test-suite, unless the
newlib being used has been explicitly configured with
--enable-newlib-iconv.  When failing, there are undefined
references to iconv, iconv_open or iconv_close for multiple
tests.

Thankfully there's a macro in newlib.h that we can check to
detect presence of iconv support for the newlib build that's
used.

libstdc++-v3:
PR libstdc++/116362
* configure.ac: Check newlib configuration whether iconv is enabled.
* configure: Regenerate.

Diff:
---
 libstdc++-v3/configure| 26 +-
 libstdc++-v3/configure.ac | 10 +-
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index fe525308ae2..305675eaa1e 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -28571,7 +28571,31 @@ _ACEOF
 
 
 
-$as_echo "#define HAVE_ICONV 1" >>confdefs.h
+# Support for iconv in newlib is configurable.
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include 
+int
+main ()
+{
+
+  #ifndef _ICONV_ENABLED
+  #error
+  #endif
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_newlib_iconv_enabled=yes
+else
+  ac_newlib_iconv_enabled=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+if test "$ac_newlib_iconv_enabled" = yes; then
+  $as_echo "#define HAVE_ICONV 1" >>confdefs.h
+
+fi
 
 $as_echo "#define HAVE_MEMALIGN 1" >>confdefs.h
 
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index ccb24a82be7..4049f54bd5a 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -376,7 +376,15 @@ dnl # rather than hardcoding that information.
   frexpl hypotl ldexpl log10l logl modfl powl sinhl sinl sqrtl
   tanhl tanl])
 
-AC_DEFINE(HAVE_ICONV)
+# Support for iconv in newlib is configurable.
+AC_TRY_COMPILE([#include ], [
+  #ifndef _ICONV_ENABLED
+  #error
+  #endif], [ac_newlib_iconv_enabled=yes], [ac_newlib_iconv_enabled=no])
+if test "$ac_newlib_iconv_enabled" = yes; then
+  AC_DEFINE(HAVE_ICONV)
+fi
+
 AC_DEFINE(HAVE_MEMALIGN)
 
 case "${target}" in