public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: Fix __cpp_lib_chrono for old std::string ABI
@ 2024-06-20 15:25 Jonathan Wakely
  2024-06-21  9:16 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Wakely @ 2024-06-20 15:25 UTC (permalink / raw)
  To: libstdc++, gcc-patches

This unfortunately means we can never increase __cpp_lib_chrono again
for the old string ABI, but I don't see any alternative (except
supporting chrono::tzdb for the old string, which will be a lot of work
that I don't want to do!)

-- >8 --

The <chrono> header is incomplete for the old std::string ABI, because
std::chrono::tzdb is only defined for the new ABI. The feature test
macro advertising full C++20 support should not be defined for the old
ABI.

libstdc++-v3/ChangeLog:

	* include/bits/version.def (chrono): Add cxx11abi = yes.
	* include/bits/version.h: Regenerate.
	* testsuite/std/time/syn_c++20.cc: Adjust expected value for
	the feature test macro.
---
 libstdc++-v3/include/bits/version.def        |  1 +
 libstdc++-v3/include/bits/version.h          |  2 +-
 libstdc++-v3/testsuite/std/time/syn_c++20.cc | 11 +++++++++--
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def
index 683b967d54b..42cdef2f526 100644
--- a/libstdc++-v3/include/bits/version.def
+++ b/libstdc++-v3/include/bits/version.def
@@ -574,6 +574,7 @@ ftms = {
     v = 201907;
     cxxmin = 20;
     hosted = yes;
+    cxx11abi = yes; // std::chrono::tzdb requires cxx11 std::string
   };
   values = {
     v = 201611;
diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h
index 4850041c0a3..1eaf3733bc2 100644
--- a/libstdc++-v3/include/bits/version.h
+++ b/libstdc++-v3/include/bits/version.h
@@ -639,7 +639,7 @@
 #undef __glibcxx_want_boyer_moore_searcher
 
 #if !defined(__cpp_lib_chrono)
-# if (__cplusplus >= 202002L) && _GLIBCXX_HOSTED
+# if (__cplusplus >= 202002L) && _GLIBCXX_USE_CXX11_ABI && _GLIBCXX_HOSTED
 #  define __glibcxx_chrono 201907L
 #  if defined(__glibcxx_want_all) || defined(__glibcxx_want_chrono)
 #   define __cpp_lib_chrono 201907L
diff --git a/libstdc++-v3/testsuite/std/time/syn_c++20.cc b/libstdc++-v3/testsuite/std/time/syn_c++20.cc
index f0b86199e9d..4a527262e9d 100644
--- a/libstdc++-v3/testsuite/std/time/syn_c++20.cc
+++ b/libstdc++-v3/testsuite/std/time/syn_c++20.cc
@@ -20,9 +20,16 @@
 
 #include <chrono>
 
+// std::chrono::tzdb is not defined for the old std::string ABI.
+#if _GLIBCXX_USE_CXX_ABI
+# define EXPECTED_VALUE 201907L
+#else
+# define EXPECTED_VALUE 201611L
+#endif
+
 #ifndef __cpp_lib_chrono
 # error "Feature test macro for chrono is missing in <chrono>"
-#elif __cpp_lib_chrono < 201907L
+#elif __cpp_lib_chrono < EXPECTED_VALUE
 # error "Feature test macro for chrono has wrong value in <chrono>"
 #endif
 
@@ -94,7 +101,7 @@ namespace __gnu_test
   using std::chrono::make12;
   using std::chrono::make24;
 
-#if _GLIBCXX_USE_CXX11_ABI
+#if __cpp_lib_chrono >= 201803L
   using std::chrono::tzdb;
   using std::chrono::tzdb_list;
   using std::chrono::get_tzdb;
-- 
2.45.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libstdc++: Fix __cpp_lib_chrono for old std::string ABI
  2024-06-20 15:25 [PATCH] libstdc++: Fix __cpp_lib_chrono for old std::string ABI Jonathan Wakely
@ 2024-06-21  9:16 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2024-06-21  9:16 UTC (permalink / raw)
  To: libstdc++, gcc-patches

Pushed to trunk now. Backport to gcc-14 needed too.

On Thu, 20 Jun 2024 at 16:27, Jonathan Wakely <jwakely@redhat.com> wrote:
>
> This unfortunately means we can never increase __cpp_lib_chrono again
> for the old string ABI, but I don't see any alternative (except
> supporting chrono::tzdb for the old string, which will be a lot of work
> that I don't want to do!)
>
> -- >8 --
>
> The <chrono> header is incomplete for the old std::string ABI, because
> std::chrono::tzdb is only defined for the new ABI. The feature test
> macro advertising full C++20 support should not be defined for the old
> ABI.
>
> libstdc++-v3/ChangeLog:
>
>         * include/bits/version.def (chrono): Add cxx11abi = yes.
>         * include/bits/version.h: Regenerate.
>         * testsuite/std/time/syn_c++20.cc: Adjust expected value for
>         the feature test macro.
> ---
>  libstdc++-v3/include/bits/version.def        |  1 +
>  libstdc++-v3/include/bits/version.h          |  2 +-
>  libstdc++-v3/testsuite/std/time/syn_c++20.cc | 11 +++++++++--
>  3 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def
> index 683b967d54b..42cdef2f526 100644
> --- a/libstdc++-v3/include/bits/version.def
> +++ b/libstdc++-v3/include/bits/version.def
> @@ -574,6 +574,7 @@ ftms = {
>      v = 201907;
>      cxxmin = 20;
>      hosted = yes;
> +    cxx11abi = yes; // std::chrono::tzdb requires cxx11 std::string
>    };
>    values = {
>      v = 201611;
> diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h
> index 4850041c0a3..1eaf3733bc2 100644
> --- a/libstdc++-v3/include/bits/version.h
> +++ b/libstdc++-v3/include/bits/version.h
> @@ -639,7 +639,7 @@
>  #undef __glibcxx_want_boyer_moore_searcher
>
>  #if !defined(__cpp_lib_chrono)
> -# if (__cplusplus >= 202002L) && _GLIBCXX_HOSTED
> +# if (__cplusplus >= 202002L) && _GLIBCXX_USE_CXX11_ABI && _GLIBCXX_HOSTED
>  #  define __glibcxx_chrono 201907L
>  #  if defined(__glibcxx_want_all) || defined(__glibcxx_want_chrono)
>  #   define __cpp_lib_chrono 201907L
> diff --git a/libstdc++-v3/testsuite/std/time/syn_c++20.cc b/libstdc++-v3/testsuite/std/time/syn_c++20.cc
> index f0b86199e9d..4a527262e9d 100644
> --- a/libstdc++-v3/testsuite/std/time/syn_c++20.cc
> +++ b/libstdc++-v3/testsuite/std/time/syn_c++20.cc
> @@ -20,9 +20,16 @@
>
>  #include <chrono>
>
> +// std::chrono::tzdb is not defined for the old std::string ABI.
> +#if _GLIBCXX_USE_CXX_ABI
> +# define EXPECTED_VALUE 201907L
> +#else
> +# define EXPECTED_VALUE 201611L
> +#endif
> +
>  #ifndef __cpp_lib_chrono
>  # error "Feature test macro for chrono is missing in <chrono>"
> -#elif __cpp_lib_chrono < 201907L
> +#elif __cpp_lib_chrono < EXPECTED_VALUE
>  # error "Feature test macro for chrono has wrong value in <chrono>"
>  #endif
>
> @@ -94,7 +101,7 @@ namespace __gnu_test
>    using std::chrono::make12;
>    using std::chrono::make24;
>
> -#if _GLIBCXX_USE_CXX11_ABI
> +#if __cpp_lib_chrono >= 201803L
>    using std::chrono::tzdb;
>    using std::chrono::tzdb_list;
>    using std::chrono::get_tzdb;
> --
> 2.45.2
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-21  9:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-20 15:25 [PATCH] libstdc++: Fix __cpp_lib_chrono for old std::string ABI Jonathan Wakely
2024-06-21  9:16 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).