[PATCH] libstdc++: implement locale support for AIX

Rainer Orth ro@CeBiTec.Uni-Bielefeld.DE
Wed Jan 13 11:57:20 GMT 2021


Hi David,

>> I agree that #ifdef's are not the correct approach, but, if you enable
>> the fallbacks for Solaris, does everything then work?  Are those
>> fallbacks portable and we solely need a better mechanism to enable
>> them on platforms that require them?
>
> it mostly compiles, with two caveats:
>
> * c_locale.h needs to include <cstdlib> for declarations of strtod and
>   friends.
>
> * Solaris <locale.h> only declares the int_p_cs_precedes etc. members of
>   struct lconv for C99+, but not for C++11+, as it should.  I'll file a
>   bug for that, but for now one can work around the issue by defining
>   _LCONV_C99 before including <locale> in monetary_members.cc.
>
> With those changes, I can at least build libstdc++ with
> --enable-clocale=ieee_1003.1-2008.  Bootstrap still running, though.

while that allowed the compilation to succeed, test results are not
good:

+FAIL: libstdc++-abi/abi_check

# of added symbols:              173
# of missing symbols:            72
# of undesignated symbols:       0
# of incompatible symbols:       144

This alone makes the patch inacceptable in its present form: breaking
the libstdc++ ABI is a non-starter.  However, I suspect this can be
avoided somehow.

+FAIL: 22_locale/classification/isblank.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/classification/isblank.cc:38: void test02(): Assertion 'std::isblank(L' ', std::locale::classic())' failed.

It turns out that this is caused by ieee_1003.1-2008/ctype_members.cc
using __bitmapsize = 11 in a couple of places, unlike the generic
version which uses 15 to accomodate variations in <ctype.h> character
classifications.

Making this change lets a few tests PASS:

@@ -3354 +3354 @@
-FAIL: 22_locale/classification/isblank.cc execution test
+PASS: 22_locale/classification/isblank.cc execution test
@@ -3621 +3621 @@
-FAIL: 22_locale/ctype/is/wchar_t/1.cc execution test
+PASS: 22_locale/ctype/is/wchar_t/1.cc execution test
@@ -3655 +3655 @@
-FAIL: 22_locale/ctype/scan/wchar_t/1.cc execution test
+PASS: 22_locale/ctype/scan/wchar_t/1.cc execution test
@@ -3657 +3657 @@
-FAIL: 22_locale/ctype/scan/wchar_t/wrapped_env.cc execution test
+PASS: 22_locale/ctype/scan/wchar_t/wrapped_env.cc execution test
@@ -10864 +10864 @@
-FAIL: 28_regex/algorithms/regex_match/ecma/wchar_t/hex.cc execution test
+PASS: 28_regex/algorithms/regex_match/ecma/wchar_t/hex.cc execution test
@@ -11070 +11070 @@
-FAIL: 28_regex/traits/wchar_t/isctype.cc execution test
+PASS: 28_regex/traits/wchar_t/isctype.cc execution test

However, there are many more which I haven't even started to
investigate.  I suspect there's one (or a few) reasons immediately
obvious to someone familiar with the code.

+FAIL: 22_locale/codecvt/in/wchar_t/3.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/codecvt/in/wchar_t/3.cc:118: void test03(): Assertion '!int_traits::compare(i_arr, i_lit, size)' failed.

+FAIL: 22_locale/codecvt/max_length/wchar_t/4.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/codecvt/max_length/wchar_t/4.cc:41: void test04(): Assertion 'k == 6' failed.

+FAIL: 22_locale/codecvt/out/wchar_t/3.cc execution test

vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/codecvt/out/wchar_t/3.cc:113: void test03(): Assertion 'r2 == codecvt_base::ok' failed.

+FAIL: 22_locale/collate/compare/wchar_t/3.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/collate/compare/wchar_t/3.cc:61: void test03(): Assertion 'i == -1' failed.

+FAIL: 22_locale/collate/transform/wchar_t/3.cc execution test

terminate called after throwing an instance of 'std::length_error'
  what():  basic_string::append

+FAIL: 22_locale/ctype/is/wchar_t/1.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/ctype/is/wchar_t/1.cc:71: void test01(): Assertion 'gctype.is(std::ctype_base::punct, c40)' failed.

+FAIL: 22_locale/ctype/is/wchar_t/wrapped_env.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/ctype/is/wchar_t/1.cc:71: void test01(): Assertion 'gctype.is(std::ctype_base::punct, c40)' failed.

+FAIL: 22_locale/ctype/scan/wchar_t/1.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/ctype/scan/wchar_t/1.cc:69: void test01(): Assertion 'gctype.scan_is((std::ctype_base::xdigit), (ca), (ca) + traits_type::length(ca)) == (ca)' failed.

+FAIL: 22_locale/ctype/scan/wchar_t/wrapped_env.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/ctype/scan/wchar_t/1.cc:69: void test01(): Assertion 'gctype.scan_is((std::ctype_base::xdigit), (ca), (ca) + traits_type::length(ca)) == (ca)' failed.

+FAIL: 22_locale/ctype/widen/wchar_t/2.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/ctype/widen/wchar_t/2.cc:39: void test02(): Assertion 'wc == static_cast<wchar_t>(0xff)' failed.

+FAIL: 22_locale/locale/cons/29217.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/locale/cons/29217.cc:33: void test01(): Assertion 'locale().name() == "LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;" "LC_TIME=C;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=C;" "LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;" "LC_MEASUREMENT=C;LC_IDENTIFICATION=C"' failed.

+FAIL: 22_locale/locale/cons/38368.cc execution test

terminate called after throwing an instance of 'std::runtime_error'
  what():  locale::facet::_S_create_c_locale name not valid

+FAIL: 22_locale/messages/members/char/1.cc execution test

vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/messages/members/char/1.cc:52: void test01(): Assertion 's01 == "bitte"' failed.

+FAIL: 22_locale/messages_byname/named_equivalence.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/messages_byname/named_equivalence.cc:58: void test01(): Assertion 's01 == "bitte"' failed.

+FAIL: 22_locale/money_get/get/wchar_t/1.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/money_get/get/wchar_t/1.cc:115: void test01(): Assertion 'result8 == digits1' failed.

+FAIL: 22_locale/money_put/put/wchar_t/1.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/money_put/put/wchar_t/1.cc:77: void test01(): Assertion 'result4 == L"7.200.000.000,00 \x20ac"' failed.

+FAIL: 22_locale/money_put/put/wchar_t/3.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/money_put/put/wchar_t/3.cc:74: void test03(): Assertion 'result4 == L"7.200.000.000,00 \x20ac"' failed.

+FAIL: 22_locale/time_put/put/char/2.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/time_put/put/char/2.cc:49: void test02(): Assertion 'result2 == "Son" || result2 == "So"' failed.

+FAIL: 22_locale/time_put/put/wchar_t/2.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/22_locale/time_put/put/wchar_t/2.cc:50: void test02(): Assertion 'result2 == L"Son" || result2 == L"So"' failed.

+FAIL: 27_io/basic_filebuf/overflow/wchar_t/11305-1.cc execution test

terminate called after throwing an instance of 'std::__ios_failure'
  what():  basic_filebuf::_M_convert_to_external conversion error: iostream error

+FAIL: 27_io/basic_filebuf/overflow/wchar_t/11305-2.cc execution test

terminate called after throwing an instance of 'std::__ios_failure'
  what():  basic_filebuf::_M_convert_to_external conversion error: iostream error

+FAIL: 27_io/basic_filebuf/overflow/wchar_t/11305-3.cc execution test

terminate called after throwing an instance of 'std::__ios_failure'
  what():  basic_filebuf::_M_convert_to_external conversion error: iostream error

+FAIL: 27_io/basic_filebuf/overflow/wchar_t/11305-4.cc execution test

terminate called after throwing an instance of 'std::__ios_failure'
  what():  basic_filebuf::_M_convert_to_external conversion error: iostream error

+FAIL: 27_io/manipulators/extended/get_time/char/2.cc execution test

vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/27_io/manipulators/extended/get_time/char/2.cc:41: void test01(): Assertion 'time1.tm_wday == 2' failed.

+FAIL: 28_regex/algorithms/regex_match/ecma/wchar_t/hex.cc execution test

terminate called after throwing an instance of 'std::regex_error'
  what():  Unexpected end of regex when ascii character.

+FAIL: 28_regex/algorithms/regex_match/extended/wstring_locale.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/wstring_locale.cc:43: void test01(): Assertion 'regex_match_debug(str2, m2, re2)' failed.

+FAIL: 28_regex/iterators/regex_token_iterator/wchar_t/wstring_02.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/28_regex/iterators/regex_token_iterator/wchar_t/wstring_02.cc:44: void test01(): Assertion 'p == end' failed.

+FAIL: 28_regex/traits/wchar_t/isctype.cc execution test

/vol/gcc/src/hg/master/solaris/libstdc++-v3/testsuite/28_regex/traits/wchar_t/isctype.cc:51: void test01(): Assertion 't.isctype(L' ', t.lookup_classname(range(blank)))' failed.

I've also added the locale handling changes in
config/os/aix/ctype_configure_char.cc to
config/os/solaris/ctype_configure_char.cc (ctype<char>::ctype), but that
made no difference.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


More information about the Gcc-patches mailing list