public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/99832] New: std::chrono::system_clock::to_time_t needs ABI tag for 32-bit time_t
@ 2021-03-30 16:01 redi at gcc dot gnu.org
  2023-06-10  9:33 ` [Bug libstdc++/99832] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2021-03-30 16:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99832

            Bug ID: 99832
           Summary: std::chrono::system_clock::to_time_t needs ABI tag for
                    32-bit time_t
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: ABI
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

chrono::system_clock defines:

      static std::time_t
      to_time_t(const time_point& __t) noexcept

This is a non-template function and its mangled name does not depend on the
return type. The mangled name is:

_ZNSt6chrono3_V212system_clock9to_time_tERKNS_10time_pointIS1_NS_8durationIlSt5ratioILl1ELl1000000000EEEEEE

For a target that allows time_t to be either 32-bit or 64-bit, we need this
mangled name to reflect the type of time_t.

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

* [Bug libstdc++/99832] std::chrono::system_clock::to_time_t needs ABI tag for 32-bit time_t
  2021-03-30 16:01 [Bug libstdc++/99832] New: std::chrono::system_clock::to_time_t needs ABI tag for 32-bit time_t redi at gcc dot gnu.org
@ 2023-06-10  9:33 ` redi at gcc dot gnu.org
  2023-07-19 18:24 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2023-06-10  9:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99832

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-06-10
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

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

* [Bug libstdc++/99832] std::chrono::system_clock::to_time_t needs ABI tag for 32-bit time_t
  2021-03-30 16:01 [Bug libstdc++/99832] New: std::chrono::system_clock::to_time_t needs ABI tag for 32-bit time_t redi at gcc dot gnu.org
  2023-06-10  9:33 ` [Bug libstdc++/99832] " redi at gcc dot gnu.org
@ 2023-07-19 18:24 ` redi at gcc dot gnu.org
  2024-01-31 11:49 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2023-07-19 18:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99832

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0

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

* [Bug libstdc++/99832] std::chrono::system_clock::to_time_t needs ABI tag for 32-bit time_t
  2021-03-30 16:01 [Bug libstdc++/99832] New: std::chrono::system_clock::to_time_t needs ABI tag for 32-bit time_t redi at gcc dot gnu.org
  2023-06-10  9:33 ` [Bug libstdc++/99832] " redi at gcc dot gnu.org
  2023-07-19 18:24 ` redi at gcc dot gnu.org
@ 2024-01-31 11:49 ` redi at gcc dot gnu.org
  2024-01-31 12:05 ` redi at gcc dot gnu.org
  2024-05-07  7:39 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2024-01-31 11:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99832

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Maybe something like this:

diff --git a/libstdc++-v3/config/os/gnu-linux/os_defines.h
b/libstdc++-v3/config/os/gnu-linux/os_defines.h
index 0af29325388..f7c73560831 100644
--- a/libstdc++-v3/config/os/gnu-linux/os_defines.h
+++ b/libstdc++-v3/config/os/gnu-linux/os_defines.h
@@ -84,7 +84,13 @@
 // Since glibc 2.34 all pthreads functions are usable without linking to
 // libpthread.
 #  define _GLIBCXX_GTHREAD_USE_WEAK 0
-# endif
+// Since glibc 2.34 using -D_TIME_BITS=64 will enable 64-bit time_t
+// for "legacy ABIs", i.e. ones that historically used 32-bit time_t.
+// This internal glibc macro will be defined iff new 64-bit time_t is in use.
+#  ifdef __USE_TIME_BITS64
+#   define _GLIBCXX_TIME_BITS64 1
+#  endif
+# endif // glibc 2.34
 #endif // __linux__

 #endif
diff --git a/libstdc++-v3/include/bits/chrono.h
b/libstdc++-v3/include/bits/chrono.h
index 579c5a266be..a63782b92ff 100644
--- a/libstdc++-v3/include/bits/chrono.h
+++ b/libstdc++-v3/include/bits/chrono.h
@@ -1242,6 +1242,9 @@ _GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2)
       now() noexcept;

       // Map to C API
+#ifdef _GLIBCXX_TIME_BITS64
+      [[__gnu__::__abi_tag__("__time64")]]
+#endif
       static std::time_t
       to_time_t(const time_point& __t) noexcept
       {
@@ -1249,6 +1252,9 @@ _GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2)
                           (__t.time_since_epoch()).count());
       }

+#ifdef _GLIBCXX_TIME_BITS64
+      [[__gnu__::__abi_tag__("__time64")]]
+#endif
       static time_point
       from_time_t(std::time_t __t) noexcept
       {

Alternatively, in <bits/c++config.h> do:

#define _GLIBCXX_TIME_BITS64_ABI_TAG

and then in config/os/gnu-linux/os_defines.h:


#  ifdef __USE_TIME_BITS64
#   undef _GLIBCXX_TIME_BITS64_ABI_TAG
#   define _GLIBCXX_TIME_BITS64_ABI_TAG [[__gnu__::__abi_tag__("__time64")]]
#  endif

Then the chrono code can just use that unconditionally instead of using #ifdef

I think for musl, newer versions use 64-bit time_t unconditionally. I'm not
sure if we can (or need to) use the abi_tag there.

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

* [Bug libstdc++/99832] std::chrono::system_clock::to_time_t needs ABI tag for 32-bit time_t
  2021-03-30 16:01 [Bug libstdc++/99832] New: std::chrono::system_clock::to_time_t needs ABI tag for 32-bit time_t redi at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-01-31 11:49 ` redi at gcc dot gnu.org
@ 2024-01-31 12:05 ` redi at gcc dot gnu.org
  2024-05-07  7:39 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2024-01-31 12:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99832

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #1)
> +// Since glibc 2.34 using -D_TIME_BITS=64 will enable 64-bit time_t
> +// for "legacy ABIs", i.e. ones that historically used 32-bit time_t.
> +// This internal glibc macro will be defined iff new 64-bit time_t is in
> use.

This is correct for current glibc releases, but in glibc master
__USE_TIME_BITS64 is defined unconditionally to 0 or 1 and tells you the size
of time_t, not whether it switched to 64-bit counter to the legacy ABI:
https://inbox.sourceware.org/libc-alpha/20240118131801.600373-1-adhemerval.zanella@linaro.org/

Yay.

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

* [Bug libstdc++/99832] std::chrono::system_clock::to_time_t needs ABI tag for 32-bit time_t
  2021-03-30 16:01 [Bug libstdc++/99832] New: std::chrono::system_clock::to_time_t needs ABI tag for 32-bit time_t redi at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2024-01-31 12:05 ` redi at gcc dot gnu.org
@ 2024-05-07  7:39 ` rguenth at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-07  7:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99832

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|14.0                        |14.2

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 14.1 is being released, retargeting bugs to GCC 14.2.

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

end of thread, other threads:[~2024-05-07  7:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-30 16:01 [Bug libstdc++/99832] New: std::chrono::system_clock::to_time_t needs ABI tag for 32-bit time_t redi at gcc dot gnu.org
2023-06-10  9:33 ` [Bug libstdc++/99832] " redi at gcc dot gnu.org
2023-07-19 18:24 ` redi at gcc dot gnu.org
2024-01-31 11:49 ` redi at gcc dot gnu.org
2024-01-31 12:05 ` redi at gcc dot gnu.org
2024-05-07  7:39 ` rguenth at gcc dot gnu.org

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).