[PATCH] testsuite: Add iconv effective-target check and fix non-unicode test failures

John David Anglin dave.anglin@bell.net
Fri Oct 30 14:03:59 GMT 2026


On hppa64-hp-hpux11.11, I explicitly disable building with iconv
and other non system libraries.  This causes the failure of various
iconv related tests.  Here we add a new effective-target check 'iconv'
to avoid these failures.

Tested on hppa64-hp-hpux11.11.

Okay?

Dave
---

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  <danglin@gcc.gnu.org>

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 --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 3c5dfd59f6f..d6d3fbb948a 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 de70f55f14a..4d5be75e02d 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 16d858c93a8..70ff71ccb71 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"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20261030/d3c2a149/attachment-0001.sig>


More information about the Libstdc++ mailing list