Rather than adding those implementations we are adding a:
using _Base::compare;
so that any compare method not implemented at __gnu_debug::basic_string
level are injected from the base class.
Also review how __gnu_debug::basic_string is tested. Now require to define
_GLIBCXX_TEST_DEBUG_STRING when running 'make check-debug'.
libstdc++-v3/ChangeLog
* include/debug/string: Add using _Base::compare.
(__gnu_debug::basic_string<>::compare(const basic_string<>&)): Remove.
(__gnu_debug::basic_string<>::compare(size_type, size_type, const basic_string<>&)):
Remove.
(__gnu_debug::basic_string<>::compare(size_type, size_type, const basic_string<>&,
size_type, size_type)): Remove.
* testsuite/util/testsuite_string.h [_GLIBCXX_TEST_DEBUG_STRING]: Include <debug/string>.
* testsuite/21_strings/basic_string/operations/compare/char/1.cc: Include testsuite_string.h
and use __gnu_test::string.
* testsuite/21_strings/basic_string/operations/compare/char/13650.cc: Likewise.
* testsuite/21_strings/basic_string/operations/compare/char/2.cc: Likewise.
* testsuite/21_strings/basic_string/operations/rfind/char/1.cc: Likewise.
* testsuite/21_strings/basic_string/operations/rfind/char/2.cc: Likewise.
* testsuite/21_strings/basic_string/operations/rfind/char/3.cc: Likewise.
* testsuite/21_strings/basic_string/operations/compare/wchar_t/1.cc:
Include testsuite_string.h
and use __gnu_test::wstring.
* testsuite/21_strings/basic_string/operations/compare/wchar_t/13650.cc: Likewise.
* testsuite/21_strings/basic_string/operations/compare/wchar_t/2.cc: Likewise.
The __scoped_lock type should be used unqualified so that we always
refer to pool::__scoped_lock, which might be the dummy fallback
implementation.
The __mutex and __scoped_lock types in <ext/concurrence.h> already work
fine without __GTHREADS being defined, but that header isn't included at
all unless _GLIBCXX_HOSTED != 0. The fallback implementation should be
used for ! _GLIBCXX_HOSTED instead of for !defined __GTHREADS.
libstdc++-v3/ChangeLog:
PR bootstrap/107221
* libsupc++/eh_alloc.cc (pool): Change preprocessor condition
for using __mutex from __GTHREADS to _GLIBCXX_HOSTED.
(pool::allocate): Remove namespace qualification to use
pool::__scoped_lock instead of __gnu_cxx::__scoped_lock.
Implement a long-standing request to support tuning the size of the
emergency buffer for allocating exceptions after malloc fails, or to
disable that buffer entirely.
It's now possible to disable the dynamic allocation of the buffer and
use a fixed-size static buffer, via --enable-libstdcxx-static-eh-pool.
This is a built-time choice that is baked into libstdc++ and so affects
all code linked against that build of libstdc++.
The size of the pool can be set by --with-libstdcxx-eh-pool-obj-count=N
which is measured in units of sizeof(void*) not bytes. A given exception
type such as std::system_error depends on the target, so giving a size
in bytes wouldn't be portable across 16/32/64-bit targets.
When libstdc++ is configured to use a dynamic buffer, the size of that
buffer can now be tuned at runtime by setting the GLIBCXX_TUNABLES
environment variable (c.f. PR libstdc++/88264). The number of exceptions
to reserve space for is controlled by the "glibcxx.eh_pool.obj_count"
and "glibcxx.eh_pool.obj_size" tunables. The pool will be sized to be
able to allocate obj_count exceptions of size obj_size*sizeof(void*) and
obj_count "dependent" exceptions rethrown by std::rethrow_exception.
With the ability to tune the buffer size, we can reduce the default pool
size on 32-bit and 16-bit targets. Most users never need to throw 1kB
exceptions in parallel from hundreds of threads after malloc is OOM. The
users who do need that can use the tunables to select larger sizes.
The old defaults can be chosen at runtime by setting GLIBCXX_TUNABLES
to:
64-bit: glibcxx.eh_pool.obj_count=64:glibcxx.eh_pool.obj_size=112
32-bit: glibcxx.eh_pool.obj_count=32:glibcxx.eh_pool.obj_size=104
Or approximated by configuring with:
64-bit: --with-libstdcxx-eh-pool-obj-count=252
32-bit: --with-libstdcxx-eh-pool-obj-count=94
libstdc++-v3/ChangeLog:
PR libstdc++/68606
* Makefile.in: Regenerate.
* acinclude.m4 (GLIBCXX_EMERGENCY_EH_ALLOC): New macro.
* configure: Regenerate.
* configure.ac: Use GLIBCXX_EMERGENCY_EH_ALLOC.
* crossconfig.m4: Check for secure_getenv.
* doc/Makefile.in: Regenerate.
* doc/xml/manual/configure.xml: Document new configure options.
* doc/xml/manual/evolution.xml: Document addition of tunables.
* doc/xml/manual/using_exceptions.xml: Document emergency
buffer and tunables.
* doc/html/*: Regenerate.
* include/Makefile.in: Regenerate.
* libsupc++/Makefile.am: Use EH_POOL_FLAGS.
* libsupc++/Makefile.in: Regenerate.
* libsupc++/eh_alloc.cc (EMERGENCY_OBJ_SIZE): Define in units
of sizeof(void*) not including the ABI's exception header.
(EMERGENCY_OBJ_COUNT): Define as target-independent calculation
based on word size.
(MAX_OBJ_COUNT): Define macro for upper limit on pool size.
(pool) [_GLIBCXX_EH_POOL_STATIC]: Use fixed-size buffer.
(pool::buffer_size_in_bytes): New static member function.
(pool::pool): Parse GLIBCXX_TUNABLES environment variable to set
pool size at runtime.
(pool::in_pool): Use std::less<void*> for total order.
(__freeres) [_GLIBCXX_EH_POOL_STATIC]: Do nothing.
(__cxa_free_exception, __cxa_free_dependent_exception): Add
[[unlikely]] attributes.
* po/Makefile.in: Regenerate.
* python/Makefile.in: Regenerate.
* src/Makefile.in: Regenerate.
* src/c++11/Makefile.in: Regenerate.
* src/c++17/Makefile.in: Regenerate.
* src/c++20/Makefile.in: Regenerate.
* src/c++98/Makefile.in: Regenerate.
* src/filesystem/Makefile.in: Regenerate.
* src/libbacktrace/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.
This change adds the configury bits to activate the build of
shared libs on VxWorks ports configured with --enable-shared,
for libraries variants where this is generally supported (rtp,
code model !large - currently not compatible with -fPIC).
Set lt_cv_deplibs_check_method in libtool.m4, so the build of
libraries know how to establish dependencies. This is useful in
configurations such as aarch64 where proper support of LSE relies
on accurate dependency information between libstdc++ and libgcc_s
to begin with.
Regenerate configure scripts to reflect libtool.m4 change.
2022-10-09 Olivier Hainque <hainque@adacore.com>
* libtool.m4 (*vxworks*): When enable_shared, set dynamic_linker
and friends for rtp !large. Assume the linker has the required
abilities and set lt_cv_deplibs_check_method.
gcc/
* config.gcc (*vxworks*): Add t-slibgcc fragment
if enable_shared.
libgcc/
* config.host (*vxworks*): When enable_shared, add
libgcc and crtstuff "shared" fragments for rtp except
large code model.
(aarch64*-wrs-vxworks7*): Remove t-slibgcc-libgcc from
the list of fragments.
2022-10-09 Olivier Hainque <hainque@adacore.com>
gcc/
* configure: Regenerate.
libatomic/
* configure: Regenerate.
libbacktrace/
* configure: Regenerate.
libcc1/
* configure: Regenerate.
libffi/
* configure: Regenerate.
libgfortran/
* configure: Regenerate.
libgomp/
* configure: Regenerate.
libitm/
* configure: Regenerate.
libobjc/
* configure: Regenerate.
liboffloadmic/
* configure: Regenerate.
liboffloadmic/
* plugin/configure: Regenerate.
libphobos/
* configure: Regenerate.
libquadmath/
* configure: Regenerate.
libsanitizer/
* configure: Regenerate.
libssp/
* configure: Regenerate.
libstdc++-v3/
* configure: Regenerate.
libvtv/
* configure: Regenerate.
lto-plugin/
* configure: Regenerate.
zlib/
* configure: Regenerate.
Constraining the primary template makes it unusable in uninstantiated
contexts.
libstdc++-v3/ChangeLog:
* include/std/type_traits (make_signed, make_unsigned): Remove
constraints on primary template.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
Undo changes to expected error in C++20 mode.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
Likewise.
* testsuite/24_iterators/range_access/range_access_cpp20_neg.cc:
Likewise.
* testsuite/20_util/make_signed/requirements/uninstantiated.cc:
New test.
* testsuite/20_util/make_unsigned/requirements/uninstantiated.cc:
New test.
Currently we only reject std::make_signed_t<bool> but not cv bool.
Similarly for std::make_unsigned_t<cv bool>.
As well as making those ill-formed, this adds a requires-clause to the
make_signed and make_unsigned primary templates. This makes
non-integral, non-enum cases fail immediately with a clear error, rather
than giving an error about __make_signed_selector<T, false, false> being
incomplete.
libstdc++-v3/ChangeLog:
* include/std/type_traits (make_signed, make_unsigned): Add
specializations for cv bool. Add requires-clause for C++20 to
improve diagnostics for non-integral, non-enum cases.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
Check cv bool.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
Likewise.
* testsuite/24_iterators/range_access/range_access_cpp20_neg.cc:
Adjust expected errors for C++20 and later.
* testsuite/lib/prune.exp: Prune "in requirements [with ...]"
lines from diagnostics.
Most libstdc++ configure args are of the form --enable-libstdcxx-xxx but
the option to build freestanding is --disable-hosted-libstdcxx. If you
accidentally type --disable-libstdcxx-hosted then it will be ignored.
This adds --disable-libstdcxx-hosted as an alias for the existing arg,
so it works whichever way you say it. If both args are used explicitly
and their values do not agree, configure fails with an error.
libstdc++-v3/ChangeLog:
* acinclude.m4 (GLIBCXX_ENABLE_HOSTED): Add libstdcxx-hosted
enable arg as an alias for hosted-libstdcxx enable arg.
* configure: Regenerate.
The <new> header is needed by std::function to use placement new, so
include it in <bits/std_function.h> instead of in <functional>.
libstdc++-v3/ChangeLog:
* include/bits/std_function.h: Include <new> but do not include
<bits/stl_function.h>.
* include/std/functional: Do not include <new>.
This matches how the issues are styled in the LWG issues list, and also
allows us to use italics for "cv" (e.g. in issue 2487).
libstdc++-v3/ChangeLog:
* doc/xml/manual/intro.xml: Add role="bold" attribute to
emphasis elements for issue titles.
* doc/html/manual/bugs.html: Regenerate.
Another case where I forgot that non-GCC compilers don't have this
built-in yet.
libstdc++-v3/ChangeLog:
* include/bits/invoke.h (__invoke_r): Check
__has_builtin(__reference_converts_from_temporary) before using
built-in.
libstdc++-v3/ChangeLog:
* testsuite/std/ranges/adaptors/join_with/1.cc: Remove unused
<sstream header.
(test04): Remove constexpr for old std::string ABI and test at
runtime.
libstdc++-v3/ChangeLog:
* include/std/type_traits (remove_cv): Use __remove_cv built-in.
(remove_reference): Use __remove_reference built-in.
(remove_cvref): Use __remove_cvref built-in. Remove inheritance
for fallback implementation.
Every use of _If_seed_seq in <random> and <ext/random> uses it with
enable_if. We can just move the enable_if into the helper alias instead
of repeating it everywhere.
libstdc++-v3/ChangeLog:
* include/bits/random.h (__is_seed_seq): Replace with ...
(_If_seed_seq_for): ... this.
* include/ext/random: Adjust to use _If_seed_seq_for.
This test checks the exception-safety of std::stable_sort if copying a
value throws. For freestanding we don't allocate in std::stable_sort
anyway, and the exception thrown via __throw_runtime_error terminates,
so disable the test.
libstdc++-v3/ChangeLog:
* testsuite/25_algorithms/stable_sort/mem_check.cc: Do nto run
for freestanding.
Everything that <coroutine> depends on is available for freestanding
now.
libstdc++-v3/ChangeLog:
PR libstdc++/107139
* include/std/coroutine: Remove all _GLIBCXXHOSTED preprocessor
conditionals.
When gcc/config.gcc defines use_gcc_stdin=wrap, GCC's <stdint.h> tries
to use libc's <stdint.h> unless -ffreestanding is used.
When libstdc++ is configured --disable-hosted-libstdcxx we want
<cstdint> to work even without -ffreestanding being given. This is a
kluge to make it include GCC's <stdint-gcc.h> directly even without
-ffreestanding.
libstdc++-v3/ChangeLog:
PR libstdc++/107134
* include/c_global/cstdint [!_GLIBCXX_HOSTED]: Include
<stdint-gcc.h> directly.
We don't compile src/c++11/functexcept.cc for freestanding, so just
define the functions used by freestanding entities as inline calls to
std::terminate.
libstdc++-v3/ChangeLog:
PR libstdc++/107135
* include/bits/functexcept.h [!_GLIBCXX_HOSTED]
(__throw_invalid_argument, __throw_out_of_range)
(__throw_out_of_range_fmt, __throw_runtime_error)
(__throw_overflow_error): Define inline.
* include/std/bitset (_M_copy_from_ptr) [!_GLIBCXX_HOSTED]:
Replace __builtin_abort with __throw_invalid_argument.
I noticed that some variables were misdocumented when using trailing
comment for documentation. I ran a search with a relatively simple
regex[1] to look for any ///s following some code that did not have a <,
and came up with these instances only.
[1]: \s*([^ ]+\s*)+///[^<].*$
libstdc++-v3/ChangeLog:
* include/std/iostream: Use ///< for inline documentation.
* include/std/limits: Likewise.
* include/experimental/internet: Likewise.
The std::bitset constructor from a character string is specified in
terms of std::basic_string and std::char_traits, but doesn't need to be.
This makes it available for freestanding.
libstdc++-v3/ChangeLog:
* include/std/bitset (bitset(const C*, size_type n, C, C))
[!_GLIBCXX_HOSTED]: Remove std::basic_string dependency.
(_M_copy_from_ptr) [!_GLIBCXX_HOSTED]: Abort instead of
throwing.
PR libstdc++/103626 - _GLIBCXX_HOSTED should respect -ffreestanding
libstdc++-v3/ChangeLog:
PR libstdc++/103626
* testsuite/lib/libstdc++.exp (check_effective_target_stacktrace):
Also require hosted.
(check_effective_target_hosted): New proc.
PR libstdc++/103626 - _GLIBCXX_HOSTED should respect -ffreestanding
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/103626
* testsuite/17_intro/headers/c++1998/stdc++.cc [!__STDC_HOSTED__]:
Do not include C headers that aren't valid for freestanding.
* testsuite/17_intro/tag_type_explicit_ctor.cc [!__STDC_HOSTED__]:
Do not test tag types that aren't defined for freestanding.
* testsuite/18_support/headers/cstdlib/functions_std.cc: Do not
check for std::getenv and std::system for freestanding.
* testsuite/17_intro/using_namespace_std_exp_neg.cc [!__STDC_HOSTED__]:
Do not test hosted parts of the standard library.
* testsuite/17_intro/using_namespace_std_tr1_neg.cc [!__STDC_HOSTED__]:
Likewise.
* testsuite/20_util/allocator_traits/members/rebind_alloc.cc [!__STDC_HOSTED__]:
Likewise.
* testsuite/20_util/allocator_traits/requirements/explicit_instantiation.cc [!HOSTED]:
Likewise.
* testsuite/20_util/headers/bitset/synopsis.cc [!__STDC_HOSTED__]: Likewise.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc [!__STDC_HOSTED__]:
Likewise.
* testsuite/20_util/pointer_traits/requirements/typedefs.cc [!__STDC_HOSTED__]:
Likewise.
* testsuite/20_util/tuple/cons/deduction.cc [!__STDC_HOSTED__]: Likewise.
* testsuite/25_algorithms/move/93872.cc [!__STDC_HOSTED__]: Likewise.
* testsuite/std/ranges/adaptors/100577.cc [!__STDC_HOSTED__]: Likewise.
In light of there being far more freestanding headers now, ad-hoc
maintenance of a subset of the install implementation has become
unsustainable. Instead, we gate off a part of the normal install routine
so that it works without HOSTED enabled, as well as subdivide lists of
headers into freestanding and hosted components, according to the HOSTED
flag.
libstdc++-v3/ChangeLog:
PR libstdc++/106953
* include/Makefile.am [!_GLIBCXX_HOSTED]: Remove
install-freestanding-headers, unifying it with the usual
install-headers
* include/Makefile.in: Regenerate.
Co-authored-by: Arsen Arsenović <arsen@aarsen.me>
libstdc++-v3/ChangeLog:
* include/precompiled/extc++.h [!_GLIBCXX_HOSTED]: Do not
include headers that aren't valid for freestanding.
* include/precompiled/stdc++.h [!_GLIBCXX_HOSTED]: Likewise.
_AC_INCLUDES_DEFAULT_REQUIREMENTS including <stdio.h> when checking for
stdint.h has prevented proper detection of whether stdint.h is present,
since it'd poison the cache variables with test results failing due to
<stdio.h> failing to include. As a solution, for autoconf versions under
2.70, we filter out that bit of code from ac_includes_default.
This issue was fixed in autoconf-2.70.
This also applies to various other headers, but was noticed when looking
into why HAVE_STDINT_H was misdefined.
libstdc++-v3/ChangeLog:
* configure.ac: Remove any lines that unconditionally include
<stdio.h> from ac_includes_default, when running Autoconf <2.70.
* configure: Regenerate.
This allows the library to switch to freestanding mode when compiling
with the -ffreestanding flag. This means you don't need a separate
libstdc++ build configured with --disable-hosted-libstdcxx in order to
compile for a freestanding environment.
The testsuite support files cannot be compiled for freestanding, so add
-fno-freestanding to override any -ffreestanding in the test flags.
libstdc++-v3/ChangeLog:
PR libstdc++/103626
* acinclude.m4 (GLIBCXX_ENABLE_HOSTED): Define _GLIBCXX_HOSTED
to __STDC_HOSTED__ for non-freestanding installations.
* configure: Regenerate.
* include/Makefile.am (${host_builddir}/c++config.h): Adjust
grep pattern.
* include/Makefile.in: Regenerate.
* testsuite/lib/libstdc++.exp (v3-build_support): Use
-fno-freestanding.
* testsuite/libstdc++-abi/abi.exp: Likewise.
In C++23 mode these tests started to FAIL because an rvalue reference
parameter can no longer be bound to an lvalue reference return type. As
confirmed by Ville (who added these tests) the problem overloads are not
intended to be called, and only exist to verify that they don't
interfere with the intended behaviour. This changes the function bodies
to just throw, so that the tests will fail if the function is called.
libstdc++-v3/ChangeLog:
* testsuite/27_io/basic_ostream/inserters_other/char/6.cc:
Change body of unused operator<< overload to throw if called.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/6.cc:
Likewise.
Since revision 33b43b0d8c std::string and other
similar typedef are ambiguous from a gdb point of view because it matches both
std::basic_string<char> and std::__cxx11::basic_string<char> symbols. For those
typedef add a workaround to accept the substitution as long as the same regardless
of __cxx11 namespace.
Also avoid to register printers for types in std::__cxx11::__8:: namespace, there is
no such symbols.
libstdc++-v3/ChangeLog:
* python/libstdcxx/v6/printers.py (Printer.add_version): Do not add version
namespace for __cxx11 symbols.
(add_one_template_type_printer): Likewise.
(add_one_type_printer): Likewise.
(FilteringTypePrinter._recognizer.recognize): Add a workaround for std::string & al
ambiguous typedef matching both std:: and std::__cxx11:: symbols.
* testsuite/libstdc++-prettyprinters/cxx17.cc: Remove obsolete
\#define _GLIBCXX_USE_CXX11_ABI 0.
* testsuite/libstdc++-prettyprinters/simple.cc: Likewise. Adapt test to accept
std::__cxx11::list.
* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
* testsuite/libstdc++-prettyprinters/whatis.cc: Likewise.
* testsuite/libstdc++-prettyprinters/80276.cc: Likewise and remove xfail for c++20
and debug mode.
* testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise.
There's no need to use a stringstream to test the to_ulong() member.
This will allow the test to be used in freestanding mode.
libstdc++-v3/ChangeLog:
* testsuite/20_util/bitset/access/to_ulong.cc: Construct bitset
from binary literal instead of using stringstream.
We can improve performance by using a char buffer instead of
basic_string. The loop bound already means we can't overflow the buffer,
and we don't need to keep writing a null character after every character
written to the buffer.
We could just use basic_string::resize(N) to zero-init the whole string,
then overwrite those chars. But that zero-init of all N chars would be
wasted in the case where we are writing to a bitset<N> with large N, but
only end up extracting one or two chars from the stream.
With this change we just use buffer of uninitialized chars. For a
small-ish bitset (currently <= 256) we can improve performance further
by using alloca instead of the heap.
libstdc++-v3/ChangeLog:
* include/std/bitset (operator>>): Use a simple buffer instead
of std::basic_string.
This makes _M_copy_from_ptr, _M_copy_from_string and _M_copy_to_string
private, and declares operator<< and operator>> as friends.
Also remove the historical _M_copy_from_string and _M_copy_to_string
overloads. Those were used before DR 396 was implemented but are
not needed now. There are no tests or docs describing them, so I don't
think we intend to support them as extensions.
libstdc++-v3/ChangeLog:
* include/std/bitset (_M_copy_from_ptr, _M_copy_from_string)
(_M_copy_to_string): Change access to private.
(_M_copy_from_string(const basic_string&, size_t, size_t)):
Remove.
(_M_copy_to_string(const basic_string&)): Remove.
The new pattern in the dg-prune-output directive doesn't work. Instead
of a messy regex full of leaning toothpicks, just match on the
diagnostic text instead of the header paths.
libstdc++-v3/ChangeLog:
* testsuite/20_util/bind/ref_neg.cc: Fix dg-prune-output
directive.