https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99832
John David Anglin <danglin at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |danglin at gcc dot gnu.org --- Comment #5 from John David Anglin <danglin at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #1) > 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. The latter causes the following warning on hppa-linux: /home/dave/debian/gcc-15/gcc-15-15.1.0/build/./prev-gcc/xg++ -B/home/dave/debian /gcc-15/gcc-15-15.1.0/build/./prev-gcc/ -B/usr/hppa-linux-gnu/bin/ -nostdinc++ - B/home/dave/debian/gcc-15/gcc-15-15.1.0/build/prev-hppa-linux-gnu/libstdc++-v3/s rc/.libs -B/home/dave/debian/gcc-15/gcc-15-15.1.0/build/prev-hppa-linux-gnu/libs tdc++-v3/libsupc++/.libs -I/home/dave/debian/gcc-15/gcc-15-15.1.0/build/prev-hp pa-linux-gnu/libstdc++-v3/include/hppa-linux-gnu -I/home/dave/debian/gcc-15/gcc -15-15.1.0/build/prev-hppa-linux-gnu/libstdc++-v3/include -I/home/dave/debian/g cc-15/gcc-15-15.1.0/src/libstdc++-v3/libsupc++ -L/home/dave/debian/gcc-15/gcc-15 -15.1.0/build/prev-hppa-linux-gnu/libstdc++-v3/src/.libs -L/home/dave/debian/gcc -15/gcc-15-15.1.0/build/prev-hppa-linux-gnu/libstdc++-v3/libsupc++/.libs -fno-P IE -c -g -O2 -fno-checking -DIN_GCC -fno-exceptions -fno-rtti -fasynchronou s-unwind-tables -W -Wall -Wno-error=narrowing -Wwrite-strings -Wcast-qual -Wmiss ing-format-attribute -Wconditionally-supported -Woverloaded-virtual -pedantic -W no-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -fno- PIE -I. -I. -I../../src/gcc -I../../src/gcc/. -I../../src/gcc/../include -I../. ./src/gcc/../libcpp/include -I../../src/gcc/../libcody -I../../src/gcc/../libdecnumber -I../../src/gcc/../libdecnumber/dpd -I../libdecnumber -I../../src/gcc/../libbacktrace -o ipa-profile.o -MT ipa-profile.o -MMD -MP -MF ./.deps/ipa-profile.TPo ../../src/gcc/ipa-profile.cc In file included from /home/dave/debian/gcc-15/gcc-15-15.1.0/build/prev-hppa-linux-gnu/libstdc++-v3/include/bits/memoryfwd.h:50, from /home/dave/debian/gcc-15/gcc-15-15.1.0/build/prev-hppa-linux-gnu/libstdc++-v3/include/memory:65, from ../../src/gcc/system.h:228, from ../../src/gcc/ipa-profile.cc:41: /home/dave/debian/gcc-15/gcc-15-15.1.0/build/prev-hppa-linux-gnu/libstdc++-v3/include/hppa-linux-gnu/bits/c++config.h:955:9: warning: '_GLIBCXX_TIME_BITS64_ABI_TAG' redefined 955 | #define _GLIBCXX_TIME_BITS64_ABI_TAG | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /home/dave/debian/gcc-15/gcc-15-15.1.0/build/prev-hppa-linux-gnu/libstdc++-v3/include/hppa-linux-gnu/bits/c++config.h:727: /home/dave/debian/gcc-15/gcc-15-15.1.0/build/prev-hppa-linux-gnu/libstdc++-v3/include/hppa-linux-gnu/bits/os_defines.h:92:12: note: this is the location of the previous definition 92 | # define _GLIBCXX_TIME_BITS64_ABI_TAG [[__gnu__::__abi_tag__("__time64")]] | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ Should the define in c++config.h overrride the define in os_defines.h or defer to it?