libstdc++: Install <coroutine> header for freestanding [PR103726]
authorJonathan Wakely <jwakely@redhat.com>
Mon, 10 Jan 2022 20:48:53 +0000 (20:48 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 11 Jan 2022 13:28:46 +0000 (13:28 +0000)
commit265d3e1a4e3d6c71d354f859302f023dc2d33f62
tree5b1571d3734b6991d9d70a9b400e6a345db19eee
parente4fe6dba90b831dbd8f5e23041c5e0e8bdd75332
libstdc++: Install <coroutine> header for freestanding [PR103726]

The standard says that <coroutine> should be present for freestanding.
That was intentionally left out of the initial implementation, but can
be done without much trouble. The header should be moved to libsupc++ at
some point in stage 1.

The standard also says that <coroutine> defines a std::hash
specialization, which was missing from our implementation. That's a
problem for freestanding (see LWG 3653) so only do that for hosted.

We can use concepts to constrain the __coroutine_traits_impl base class
when compiled with concepts enabled. In a pure C++20 implementation we
would not need that base class at all and could just use a constrained
partial specialization of coroutine_traits. But the absence of the
__coroutine_traits_impl<R, void> base would create an ABI difference
between the non-standard C++14/C++17 support for coroutines and the same
code compiled as C++20. If we drop support for <coroutine> pre-C++20 we
should revisit this.

libstdc++-v3/ChangeLog:

PR libstdc++/103726
* include/Makefile.am: Install <coroutine> for freestanding.
* include/Makefile.in: Regenerate.
* include/std/coroutine: Adjust headers and preprocessor
conditions.
(__coroutine_traits_impl): Use concepts when available.
[_GLIBCXX_HOSTED] (hash<coroutine_handle>): Define.
libstdc++-v3/include/Makefile.am
libstdc++-v3/include/Makefile.in
libstdc++-v3/include/std/coroutine