On Okt 09 2025, Jonathan Wakely wrote:
> diff --git a/libstdc++-v3/include/bits/this_thread_sleep.h
> b/libstdc++-v3/include/bits/this_thread_sleep.h
> index 57f89f858952..01f25dda2af0 100644
> --- a/libstdc++-v3/include/bits/this_thread_sleep.h
> +++ b/libstdc++-v3/include/bits/this_thread_sleep.h
> @@ -36,6 +36,7 @@
>
> #if __cplusplus >= 201103L
> #include <bits/chrono.h> // std::chrono::*
> +#include <ext/numeric_traits.h> // __int_traits
>
> #ifdef _GLIBCXX_USE_NANOSLEEP
> # include <cerrno> // errno, EINTR
> @@ -59,11 +60,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> {
> #ifndef _GLIBCXX_NO_SLEEP
>
> -#ifndef _GLIBCXX_USE_NANOSLEEP
> - void
> - __sleep_for(chrono::seconds, chrono::nanoseconds);
> -#endif
> -
> /// this_thread::sleep_for
> template<typename _Rep, typename _Period>
> inline void
> @@ -71,18 +67,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> {
> if (__rtime <= __rtime.zero())
> return;
> - auto __s = chrono::duration_cast<chrono::seconds>(__rtime);
> - auto __ns = chrono::duration_cast<chrono::nanoseconds>(__rtime - __s);
> +
> + struct timespec __ts = chrono::__to_timeout_timespec(__rtime);
This breaks *-elf targets like riscv64-elf and rx-elf and also arm-eabi
where defined _GLIBCXX_USE_NANOSLEEP || defined
_GLIBCXX_USE_CLOCK_REALTIME || defined _GLIBCXX_HAS_GTHREADS is false,
thus chrono::__to_timeout_timespec is not defined.
In file included from
/home/abuild/rpmbuild/BUILD/cross-riscv64-elf-gcc16-16.0.0+git4435-build/gcc-16.0.0+git4435/obj-x86_64-suse-linux/riscv64-elf/libstdc++-v3/include/thread:48,
from ../../../../../libstdc++-v3/src/c++11/thread.cc:29:
/home/abuild/rpmbuild/BUILD/cross-riscv64-elf-gcc16-16.0.0+git4435-build/gcc-16.0.0+git4435/obj-x86_64-suse-linux/riscv64-elf/libstdc++-v3/include/bits/this_thread_sleep.h:
In function 'void std::this_thread::sleep_for(const
std::chrono::duration<_Rep1, _Period1>&)':
/home/abuild/rpmbuild/BUILD/cross-riscv64-elf-gcc16-16.0.0+git4435-build/gcc-16.0.0+git4435/obj-x86_64-suse-linux/riscv64-elf/libstdc++-v3/include/bits/this_thread_sleep.h:71:40:
error: '__to_timeout_timespec' is not a member of 'std::chrono'
[-Wtemplate-body]
71 | struct timespec __ts = chrono::__to_timeout_timespec(__rtime);
| ^~~~~~~~~~~~~~~~~~~~~
make[5]: *** [Makefile:685: thread.lo] Error 1
--
Andreas Schwab, SUSE Labs, [email protected]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."