This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: --enable-libstdcxx-time changes ABI?

On 2 December 2012 04:36, Kenny Simpson wrote:
> Hello,
> documents the --enable-libstdcxx-time options, but, unlike some of the other options, does not mention that it affects ABI.
> or maybe I'm not understanding ABI-breakage.
> My understanding of the affect of this is that  std::chrono::system_clock::time_point would become a different type.
> std::chrono::system_clock::time_point is defined as:
>       typedef chrono::time_point<system_clock, duration>        time_point;
> and 'duration' depends on a configuration-time setting based the enable-libstdcxx-time:
>     struct system_clock
>     {
>       typedef chrono::nanoseconds                               duration;
>       typedef chrono::microseconds                              duration;
> #else
>       typedef chrono::seconds                                   duration;
> #endif
> What makes this affect the ABI is system_clock::now:
>       static time_point
>       now() noexcept;
> Since only the return type is affected, and since the return type is not part of the mangled name, the exported symbol is not affected.
> However, if a program at runtime were to run against a built with a differing option, the results would be times/durations that are off by large factors - silently.  The program could have compiled assuming nanoseconds, only to run against a libstdc++ that returns microseconds.
> As such, it seems it would never be safe to mix code that was built with differing flavors of libstdcxx-time.  If this is true, a note in the documentation would be nice - even if this isn't considered ABI-breakage since the exported symbols aren't affected.

Hi Kenny,

I agree this should be documented, I'll update the docs for

N.B. currently the higher resolution system_clock is only available
with --enable-libstdcxx-time=rt which causes to link to, which is a very user-visible change (although maybe not an
obvious one unless you look for it.)  At some point a future version
of GCC when used with glibc 2.17 or later will be able to use
clock_gettime and CLOCK_REALTIME without, which would
effectively make --enable-libstdcxx-time=rt equivalent to
--enable-libstdcxx-time=yes and we will need to keep in mind that it
can affect the ABI.

I wonder if we want to use the abi tag attribute to make system_clock
mangle differently depending whether it uses nanosecond, microsecond
or second resolution.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]