Created attachment 30800 [details] Relax constraints on std::to_w?string and std:sto* The GCC build system's feature check that must be passed to enable support for std::to_w?string and std::sto.* asks for the underlying C library to support a large set of C99 functions, including C99 real and complex math. uClibc does not implement complex math function and the C99 real math functions are optional. The implementation of std::to_w?string and std::sto.* do not use complex math functions and probably never will, so it is a bit sad that a libstdc++ built against uClibc does not provide std::to_w?string and std::sto.* The feature check should be relaxed to only requires the functions that are actually used to implement std::to_w?string and std::sto.* The attached patch is an example of how it could be done.
In any case, please send patches to the mailing list, attached to bug report will be easily overlooked. More specifically, if we are going to be more fine grained about C99 support, other headers have to be consistently updated.
I am one of the core developers of Buildroot, an embedded Linux build system, which offers amongst other choices, the possibility of building a Linux system based on the uClibc library. As such, we are facing the same problem as the one reported by Nicolas Cavallari in this bug report: uClibc doesn't implement the C99 complex maths functions, and this prevents libstdc++ from providing many std-c++11 methods that are clearly unrelated to complex maths. Has any progress been made towards applying Nicolas's patch?
No, but I do want to improve the use of those macros, and fix other issues like PR 11196 at the same time.
Created attachment 33060 [details] 7 patches for being more specific with feature checks, in mbox format. Following Paolo's comment, i made some other patches a while ago, using more specific feature checks everywhere. The only part where _GLIBCXX_USE_C99 is still needed is when determining whether the time functions allows one or two leap seconds. However, my attemps to run the testsuite were always met with frustration and undeterministic results, so i delayed it and kept working around the problem in my programs. I attach my untested patches here. Maybe i'll fight with the testsuite again, maybe not.
Author: redi Date: Fri Nov 13 14:51:25 2015 New Revision: 230324 URL: https://gcc.gnu.org/viewcvs?rev=230324&root=gcc&view=rev Log: More fine-grained autoconf checks for C99 library 2015-11-13 Jennifer Yao <jenny.hyphen.fa@gmail.com> Jonathan Wakely <jwakely@redhat.com> PR libstdc++/58393 PR libstdc++/61580 * acinclude.m4 (GLIBCXX_ENABLE_C99): Perform tests twice, with -std=c++11 as well as -std=c++98, and define separate macros for each. Cache the results of checking for complex math and wide character functions. Reformat for readability. * config.h.in: Regenerate. * include/bits/c++config: Define _GLIBCXX_USE_C99_XXX macros to either _GLIBCXX98_USE_C99_XXX or _GLIBCXX11_USE_C99_XXX according to language standard in use. * config/locale/dragonfly/c_locale.h (std::__convert_from_v): Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO. * config/locale/generic/c_locale.h (std::__convert_from_v): Likewise. * config/locale/gnu/c_locale.h (std::__convert_from_v): Likewise. * config/os/bsd/dragonfly/os_defines.h: Define _GLIBCXX_USE_C99_STDIO, _GLIBCXX_USE_C99_STDLIB, and _GLIBCXX_USE_C99_WCHAR. * configure: Regenerate. * include/bits/basic_string.h: Make numeric conversion functions depend on _GLIBCXX_USE_C99_STDIO, _GLIBCXX_USE_C99_STDLIB, or _GLIBCXX_USE_C99_WCHAR, instead of _GLIBCXX_USE_C99. * include/ext/vstring.h: Likewise. * include/bits/locale_facets.tcc (std::num_put::_M_insert_float): Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO. * include/bits/locale_facets_nonio.tcc (std::money_put::do_put): Likewise. * include/c_compatibility/math.h: Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_MATH. * include/c_compatibility/wchar.h: Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR. * include/c_global/cstdio: Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO. * include/c_global/cstdlib: Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDLIB. * include/c_global/cwchar: Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR. * include/c_std/cstdio: Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO. * include/c_std/cstdlib: Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDLIB. * include/c_std/cwchar: Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR. * include/tr1/cstdio: Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO. * include/tr1/cstdlib: Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDLIB. * include/tr1/cwchar: Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR. * include/tr1/stdlib.h: Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDLIB. * src/c++98/locale_facets.cc (std::__num_base::_S_format_float): Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO. * testsuite/18_support/exception_ptr/60612-terminate.cc: Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDLIB. * testsuite/18_support/exception_ptr/60612-unexpected.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc (test01): Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/ stof.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/ stoi.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/ stol.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/ stold.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/ stoll.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/ stoul.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/ stoull.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/wchar_t/ to_wstring.cc: Likewise. * testsuite/26_numerics/headers/cstdlib/13943.cc: Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDLIB. * testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc: Likewise. * testsuite/lib/libstdc++.exp (check_v3_target_string_conversions): Change preprocessor #if conditional so that it uses _GLIBCXX_USE_C99_STDIO, _GLIBCXX_USE_C99_STDLIB, and _GLIBCXX_USE_C99_WCHAR, instead of _GLIBCXX_USE_C99. * testsuite/tr1/8_c_compatibility/cmath/templates.cc: Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_MATH. * testsuite/tr1/8_c_compatibility/cstdio/functions.cc: Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO. * testsuite/tr1/8_c_compatibility/cstdlib/functions.cc: Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDLIB. * testsuite/tr1/8_c_compatibility/cstdlib/types_std_tr1.cc: Likewise. * testsuite/tr1/8_c_compatibility/cwchar/functions.cc: Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_WCHAR. * testsuite/util/testsuite_fs.h: Replace _GLIBCXX_USE_C99 with _GLIBCXX_USE_C99_STDIO. Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/acinclude.m4 trunk/libstdc++-v3/config.h.in trunk/libstdc++-v3/config/locale/dragonfly/c_locale.h trunk/libstdc++-v3/config/locale/generic/c_locale.h trunk/libstdc++-v3/config/locale/gnu/c_locale.h trunk/libstdc++-v3/config/os/bsd/dragonfly/os_defines.h trunk/libstdc++-v3/configure trunk/libstdc++-v3/include/bits/basic_string.h trunk/libstdc++-v3/include/bits/c++config trunk/libstdc++-v3/include/bits/locale_facets.tcc trunk/libstdc++-v3/include/bits/locale_facets_nonio.tcc trunk/libstdc++-v3/include/c_compatibility/math.h trunk/libstdc++-v3/include/c_compatibility/wchar.h trunk/libstdc++-v3/include/c_global/cstdio trunk/libstdc++-v3/include/c_global/cstdlib trunk/libstdc++-v3/include/c_global/cwchar trunk/libstdc++-v3/include/c_std/cstdio trunk/libstdc++-v3/include/c_std/cstdlib trunk/libstdc++-v3/include/c_std/cwchar trunk/libstdc++-v3/include/ext/vstring.h trunk/libstdc++-v3/include/std/complex trunk/libstdc++-v3/include/tr1/cstdio trunk/libstdc++-v3/include/tr1/cstdlib trunk/libstdc++-v3/include/tr1/cwchar trunk/libstdc++-v3/include/tr1/stdlib.h trunk/libstdc++-v3/src/c++98/locale_facets.cc trunk/libstdc++-v3/testsuite/18_support/exception_ptr/60612-terminate.cc trunk/libstdc++-v3/testsuite/18_support/exception_ptr/60612-unexpected.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc trunk/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/13943.cc trunk/libstdc++-v3/testsuite/26_numerics/headers/cstdlib/types_std_c++0x.cc trunk/libstdc++-v3/testsuite/lib/libstdc++.exp trunk/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/templates.cc trunk/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdio/functions.cc trunk/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/functions.cc trunk/libstdc++-v3/testsuite/tr1/8_c_compatibility/cstdlib/types_std_tr1.cc trunk/libstdc++-v3/testsuite/tr1/8_c_compatibility/cwchar/functions.cc trunk/libstdc++-v3/testsuite/util/testsuite_fs.h
Should be fixed on trunk now.