https://gcc.gnu.org/g:6364ded77a6d94b04d5561fe0a99cd268424a59e

commit r17-6803-g6364ded77a6d94b04d5561fe0a99cd268424a59e
Author: John David Anglin <[email protected]>
Date:   Sun Nov 29 09:22:07 2026 -0500

    testsuite: Add iconv effective-target check and fix non-unicode test 
failures
    
    On targets where the toolchain is explicitly configured and built
    without iconv character set conversion support, passing execution
    charset options like '-fexec-charset=ISO-8859-1' results in compilation
    or linkage errors.  This causes unexpected regressions in the libstdc++
    format testsuite.
    
    This patch addresses the failures by introducing a new caching
    effective-target check 'iconv' in the testsuite framework. The check
    tests if the compiler can successfully compile and link an executable
    when passing a basic execution charset argument.
    
    The format tests 'debug_nonunicode.cc' and 'fill_nonunicode.cc' are
    updated to utilize this new effective target check instead of the older
    literal requirement macro. They are also updated to explicitly require
    the 'en_US.ISO8859-1' named locale to ensure runtime formatting stability
    on environments with restricted system locales.
    
    2026-10-28  John David Anglin  <[email protected]>
    
    gcc/testsuite/ChangeLog:
    
            * lib/target-supports.exp (check_effective_target_iconv): New
            effective-target check to verify execution charset compilation.
    
    libstdc++-v3/ChangeLog:
    
            * testsuite/std/format/debug_nonunicode.cc: Use the new
            dg-require-effective-target iconv macro, and add a requirement
            for the en_US.ISO8859-1 locale.
            * testsuite/std/format/fill_nonunicode.cc: Likewise.

Diff:
---
 gcc/testsuite/lib/target-supports.exp                 | 12 ++++++++++++
 libstdc++-v3/testsuite/std/format/debug_nonunicode.cc |  3 ++-
 libstdc++-v3/testsuite/std/format/fill_nonunicode.cc  |  3 ++-
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 291c29932913..5f811a12c275 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -953,6 +953,18 @@ proc check_effective_target_hostedlib { } {
     return 1
 }
 
+# Return 1 if the target compiler supports basic execution charset
+# conversions via iconv.
+proc check_effective_target_iconv { } {
+    return [check_cached_effective_target iconv {
+       return [check_no_compiler_messages iconv executable {
+           int main () {
+               return 0;
+           }
+       } "-fexec-charset=ISO-8859-1"]
+    }]
+}
+
 # Check to see that file I/O functions are available.
 proc check_effective_target_fileio { } {
     return [check_no_compiler_messages fileio_available executable {
diff --git a/libstdc++-v3/testsuite/std/format/debug_nonunicode.cc 
b/libstdc++-v3/testsuite/std/format/debug_nonunicode.cc
index de70f55f14a9..4d5be75e02d4 100644
--- a/libstdc++-v3/testsuite/std/format/debug_nonunicode.cc
+++ b/libstdc++-v3/testsuite/std/format/debug_nonunicode.cc
@@ -1,6 +1,7 @@
 // { dg-options "-fexec-charset=ISO-8859-1" }
-// { dg-require-iconv "ISO-8859-1" }
 // { dg-do run { target c++23 } }
+// { dg-require-effective-target iconv }
+// { dg-require-namedlocale "en_US.ISO8859-1" }
 // { dg-add-options no_pch }
 
 #include "debug.cc"
diff --git a/libstdc++-v3/testsuite/std/format/fill_nonunicode.cc 
b/libstdc++-v3/testsuite/std/format/fill_nonunicode.cc
index 16d858c93a8d..70ff71ccb717 100644
--- a/libstdc++-v3/testsuite/std/format/fill_nonunicode.cc
+++ b/libstdc++-v3/testsuite/std/format/fill_nonunicode.cc
@@ -1,6 +1,7 @@
 // { dg-options "-fexec-charset=ISO-8859-1" }
-// { dg-require-iconv "ISO-8859-1" }
 // { dg-do run { target c++20 } }
+// { dg-require-effective-target iconv }
+// { dg-require-namedlocale "en_US.ISO8859-1" }
 // { dg-add-options no_pch }
 
 #include "fill.cc"

Reply via email to