Bug 58393 - Please relax feature check for std::to_string and std::sto* for uClibc
Summary: Please relax feature check for std::to_string and std::sto* for uClibc
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.9.0
: P3 enhancement
Target Milestone: 6.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-11 15:58 UTC by nicolas.cavallari
Modified: 2015-11-14 05:27 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-07-02 00:00:00


Attachments
Relax constraints on std::to_w?string and std:sto* (1.16 KB, patch)
2013-09-11 15:58 UTC, nicolas.cavallari
Details | Diff
7 patches for being more specific with feature checks, in mbox format. (5.92 KB, patch)
2014-07-03 12:37 UTC, nicolas.cavallari
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description nicolas.cavallari 2013-09-11 15:58:34 UTC
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.
Comment 1 Paolo Carlini 2013-09-11 16:32:08 UTC
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.
Comment 2 Thomas Petazzoni 2014-07-02 21:59:02 UTC
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?
Comment 3 Jonathan Wakely 2014-07-02 23:46:02 UTC
No, but I do want to improve the use of those macros, and fix other issues like PR 11196 at the same time.
Comment 4 nicolas.cavallari 2014-07-03 12:37:16 UTC
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.
Comment 5 Jonathan Wakely 2015-11-13 14:51:57 UTC
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
Comment 6 Jonathan Wakely 2015-11-13 16:58:10 UTC
Should be fixed on trunk now.