[PATCHv4] libstdc++: Move tai_- and gps_clock::now impls out of ABI
Nathan Myers
ncm@cantrip.org
Tue Sep 2 16:15:18 GMT 2025
I have an edit where I revert all four changes from
"__cpp_lib_chrono >= 201803L" back to "__cplusplus >= 202002L",
which I think un-breaks it.
But you suggest I further change these to check
"#if defined(__glibcxx_chrono_cxx20)" instead?
And leave mentions of "&& _GLIBCXX_HOSTED" in place as-is?
On 9/2/25 10:40 AM, Jonathan Wakely wrote:
> On Tue, 26 Aug 2025 at 18:31, Nathan Myers wrote:
>> It also changes #if guards to mention the actual __cpp_lib_*
>> feature gated, not just the language version, for clarity.
>
> To expand on my previous mail about this part ...
>
>
>
>> --- a/libstdc++-v3/include/std/chrono
>> +++ b/libstdc++-v3/include/std/chrono
>> @@ -22,6 +22,8 @@
>> // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
>> // <http://www.gnu.org/licenses/>
>>
>> +// [time]
>> +
>> /** @file include/chrono
>> * This is a Standard C++ Library header.
>> * @ingroup chrono
>> @@ -42,12 +44,16 @@
>> # include <bits/c++0x_warning.h>
>> #else
>>
>> +#define __glibcxx_want_chrono
>> +#define __glibcxx_want_chrono_udls
>> +#include <bits/version.h>
>> +
>> #include <bits/chrono.h>
>>
>> -#if __cplusplus >= 202002L
>> +#if __cpp_lib_bitops >= 201907L
>> # include <bit> // __countr_zero
>> #endif
>> -#if __cplusplus >= 202002L && _GLIBCXX_HOSTED
>> +#if __cpp_lib_chrono >= 201803L && _GLIBCXX_HOSTED
>
> __cpp_lib_chrono is not defined for freestanding, so checking HOSTED
> here is redundant.
>
>> # include <sstream>
>> # include <string>
>> # include <vector>
>> @@ -56,10 +62,6 @@
>> # include <bits/unique_ptr.h>
>> #endif
>>
>> -#define __glibcxx_want_chrono
>> -#define __glibcxx_want_chrono_udls
>> -#include <bits/version.h>
>> -
>> namespace std _GLIBCXX_VISIBILITY(default)
>> {
>> _GLIBCXX_BEGIN_NAMESPACE_VERSION
>> @@ -79,7 +81,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>> */
>> namespace chrono
>> {
>> -#if __cplusplus >= 202002L
>> +#if __cpp_lib_chrono >= 201803L
>
> This changes it from "any C++20 compilation" to "hosted C++20 with new
> std::string ABI".
>
>> /// @addtogroup chrono
>> /// @{
>> struct local_t { };
>> @@ -175,13 +177,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>> using period = system_clock::period;
>> using duration = chrono::duration<rep, period>;
>> using time_point = chrono::time_point<tai_clock>;
>> - static constexpr bool is_steady = false; // XXX true for CLOCK_TAI?
>> + static constexpr bool is_steady = false;
>>
>> - // TODO move into lib, use CLOCK_TAI on linux, add extension point.
>> [[nodiscard]]
>> static time_point
>> - now()
>> - { return from_utc(utc_clock::now()); }
>> + now(); // in src/c++20/clock.cc
>>
>> template<typename _Duration>
>> [[nodiscard]]
>> @@ -215,13 +215,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>> using period = system_clock::period;
>> using duration = chrono::duration<rep, period>;
>> using time_point = chrono::time_point<gps_clock>;
>> - static constexpr bool is_steady = false; // XXX
>> + static constexpr bool is_steady = false;
>>
>> - // TODO move into lib, add extension point.
>> [[nodiscard]]
>> static time_point
>> - now()
>> - { return from_utc(utc_clock::now()); }
>> + now(); // in src/c++20/clock.cc
>>
>> template<typename _Duration>
>> [[nodiscard]]
>> @@ -3321,7 +3319,7 @@ namespace __detail
>> #endif // C++20
>> } // namespace chrono
>>
>> -#if __cplusplus >= 202002L
>> +#if __cpp_lib_chrono >= 201803L
>
> Ditto here
>
>> inline namespace literals
>> {
>> inline namespace chrono_literals
>> @@ -3350,7 +3348,7 @@ namespace __detail
>> _GLIBCXX_END_NAMESPACE_VERSION
>> } // namespace std
>>
>> -#if __cplusplus >= 202002L && _GLIBCXX_HOSTED
>> +#if __cpp_lib_chrono >= 201803L && _GLIBCXX_HOSTED
>
> And this goes from "hosted C++20" to "hosted C++20 with new ABI"
>
>> # include <bits/chrono_io.h>
>> #endif
>>
>
>
> Instead of just reverting this part, I'll add a new
> __glibcxx_chrono_cxx20 internal macro that doesn't depend on the new
> string ABI and can be used here.
>
More information about the Libstdc++
mailing list