]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Fix build failures for avr
authorJonathan Wakely <jwakely@redhat.com>
Tue, 31 Jan 2023 22:16:31 +0000 (22:16 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 2 Feb 2023 09:34:15 +0000 (09:34 +0000)
commitaa18735f7aa99b40c56b3e3aacb1b28cb805bb90
tree43c07f5f6502ab4c43092c4d70be49179e81d9db
parent953c3c68f8940d03bfded87dc79635451e1892b0
libstdc++: Fix build failures for avr

The abr-libc <errno.h> does not define EOVERFLOW, which means that
std::errc::value_too_large is not defined, and so <charconv> cannot be
compiled. Define value_too_large for avr with a value that does not
clash with any that is defined in <errno.h>. This is a kluge to fix
bootstrap for avr; it can be removed after PR libstdc++/104883 is
resolved.

The avr-libc <errno.h> fails to meet the C and POSIX requirements that
each error macro has a distinct integral value, and is usable in #if
directives. Add a special case for avr to system_error.cc so that only
the valid errors are recognized. Also disable the errno checks in
std::filesystem::remove_all that assume a meaningful value for errno.

On avr-libc <unistd.h> exists but does not define the POSIX functions
needed by std::filesystem, so _GLIBCXX_HAVE_UNISTD_H is not sufficient
to check for basic POSIX APIs. Check !defined __AVR__ as well as
_GLIBCXX_HAVE_UNISTD_H before using those functions. This is a kluge and
we should really have a specific macro that says the required functions
are available.

libstdc++-v3/ChangeLog:

* config/os/generic/error_constants.h (errc::value_too_large)
[__AVR__]: Define.
* src/c++11/system_error.cc
(system_category::default_error_condition) [__AVR__]: Only match
recognize values equal to EDOM, ERANGE, ENOSYS and EINTR.
* src/c++17/fs_ops.cc (fs::current_path) [__AVR__]: Do not check
for ENOENT etc. in switch.
(fs::remove_all) [__AVR__]: Likewise.
* src/filesystem/ops-common.h [__AVR__]: Do not use POSIX open,
close etc.

(cherry picked from commit 2d2e163d12f64a5e68f9e0381751ed9d5d6d3617)
libstdc++-v3/config/os/generic/error_constants.h
libstdc++-v3/src/c++11/system_error.cc
libstdc++-v3/src/c++17/fs_ops.cc
libstdc++-v3/src/filesystem/ops-common.h