This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [patch] Default to --enable-libstdcxx-time=auto
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- Cc: Rainer Orth <ro at cebitec dot uni-bielefeld dot de>, Benjamin Kosnik <bkoz at redhat dot com>, Paolo Carlini <paolo dot carlini at oracle dot com>, libstdc++ <libstdc++ at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 24 May 2013 22:10:04 +0200
- Subject: Re: [patch] Default to --enable-libstdcxx-time=auto
- References: <yddk3mopxat dot fsf at lokon dot CeBiTec dot Uni-Bielefeld dot DE> <20130524132117 dot GT1377 at tucnak dot redhat dot com> <ydd38tcpkks dot fsf at lokon dot CeBiTec dot Uni-Bielefeld dot DE> <20130524134056 dot GU1377 at tucnak dot redhat dot com> <CAH6eHdScm3PHL_HVJU7rKywvDoPwgeU_OJ1kDAS12y-v5RJbwg at mail dot gmail dot com> <20130524140748 dot GV1377 at tucnak dot redhat dot com> <20130524141622 dot GW1377 at tucnak dot redhat dot com> <CAH6eHdRZPUrsF=kh-mQRT4kj7Khq9YrEYSj3Rf7jRLtpgZuiAg at mail dot gmail dot com> <20130524150357 dot GX1377 at tucnak dot redhat dot com> <CAH6eHdTSVSj5M0ptSOmW9Bj86Kyjw-=KtUZh3-uiRAA9O-h1DQ at mail dot gmail dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, May 24, 2013 at 04:22:43PM +0100, Jonathan Wakely wrote:
> On 24 May 2013 16:03, Jakub Jelinek wrote:
> >
> > So, adjusted patches attached, ok for trunk/4.8 if they pass
> > bootstrap/regtest?
>
> Yes, they're OK - thanks for sorting it out.
Note, I've already committed the patches, but further testing using
#include <chrono>
#include <unistd.h>
int
main()
{
using namespace std::chrono;
steady_clock::time_point t1 = steady_clock::now();
sleep (2);
steady_clock::time_point t2 = steady_clock::now();
auto d1 = t1.time_since_epoch ();
auto d2 = t2.time_since_epoch ();
long long l1 = d1.count ();
long long l2 = d1.zero ().count ();
long long l3 = d1.min ().count ();
long long l4 = d1.max ().count ();
long long l5 = d2.count ();
__builtin_printf ("%lld %lld %lld %lld %lld %lld\n", l1, l2, l3, l4, l5, l5 - l1);
system_clock::time_point t3 = system_clock::now();
sleep (2);
system_clock::time_point t4 = system_clock::now();
auto d3 = t3.time_since_epoch ();
auto d4 = t4.time_since_epoch ();
l1 = d3.count ();
l2 = d3.zero ().count ();
l3 = d3.min ().count ();
l4 = d3.max ().count ();
l5 = d4.count ();
__builtin_printf ("%lld %lld %lld %lld %lld %lld\n", l1, l2, l3, l4, l5, l5 - l1);
return 0;
}
seems to point at another possible serious ABI issue.
g++ 4.7 compiled, linked and run against:
1369424708027221 0 -9223372036854775808 9223372036854775807 1369424710027308 2000087
1369424710027397 0 -9223372036854775808 9223372036854775807 1369424712027522 2000125
g++ 4.8 head (with the patch) with
- if test x"$ac_has_clock_monotonic_syscall" = x"yes"; then
+ if test x"$ac_has_clock_monotonic_syscall" = x"yesz"; then
in configure (thus, typedef system_clock steady_clock; plus
steady_clock::now() in libstdc++):
1369424714156881 0 -9223372036854775808 9223372036854775807 1369424716157039 2000158
1369424716157108 0 -9223372036854775808 9223372036854775807 1369424718157236 2000128
g++ 4.8 head (with the patch):
1421990971125719 0 -9223372036854775808 9223372036854775807 1421992971246052 2000120333
1369424821707660285 0 -9223372036854775808 9223372036854775807 1369424823707805952 2000145667
g++ 4.8 head compiled, but run against libstdc++ built with that configure hack:
1369424720776367000 0 -9223372036854775808 9223372036854775807 1369424722776515000 2000148000
1369424722776583 0 -9223372036854775808 9223372036854775807 1369424724776704 2000121
4.7 compiled, run against 4.8 head libstdc++.so:
1369425485748333050 0 -9223372036854775808 9223372036854775807 1369425487748453585 2000120535
1369425487748521770 0 -9223372036854775808 9223372036854775807 1369425489748695701 2000173931
4.7 compiled, run against 4.8 head with configure hack libstdc++.so:
1369425496792688 0 -9223372036854775808 9223372036854775807 1369425498792910 2000222
1369425498792966 0 -9223372036854775808 9223372036854775807 1369425500793089 2000123
So, there is a minor issue that what is std::chrono::steady_clock has
changed, if you say use it as a function parameter, it will mangle
differently before/after. Guess not that big a deal, after all, C++11
support is still experimental, right?
But the more important issue is that std::chrono::system_clock broke,
code compiled against the old headers will assume
std::chrono::system_clock::duration is microseconds resolution on Linux,
while code compiled against the new headers will assume it is in
nanoseconds resolution. That is because of:
#ifdef _GLIBCXX_USE_CLOCK_REALTIME
typedef chrono::nanoseconds duration;
#elif defined(_GLIBCXX_USE_GETTIMEOFDAY)
typedef chrono::microseconds duration;
#else
typedef chrono::seconds duration;
#endif
Thus, I'm afraid we can't ABI compatibly change either of these macros,
unless we e.g. keep old std::chrono::system_clock as is and introduce
std::chrono::__whatever::system_clock or whatever, that will be typedefed
as std::chrono::system_clock. Is it a big issue if system_clock will have
just old resolution (usec) and =auto code is reverted to only tweak
steady_clock (aka. _GLIBCXX_USE_CLOCK_MONOTONIC) (then for 4.8 the change
would be just to drop
ac_has_clock_realtime=yes
line from if test x"$ac_has_clock_monotonic_syscall" = x"yes"; then)?
Ugh, C++ and ABI doesn't go well together...
Jakub