[libcxx] r274403 - Work around ABI break caused by C++17 inline variables.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 1 16:45:15 PDT 2016
On Fri, Jul 1, 2016 at 4:37 PM, Eric Fiselier <eric at efcs.ca> wrote:
> The attribute is ignored unless it is placed on the in-class declaration
> of the member. It has no effect when applied to the explicit definition.
>
Ugh, right, attributes added after the definition aren't well-treated.
Seems reasonable to me for us to emit a strong definition of the variable
(linkonce_odr -> weak_odr) if it has an out-of-line declaration, for
compatibility with cases like this. That way you wouldn't need this change
at all.
> I would rather keep the workaround internal than make the change in the
> headers.
>
Oh, sure, changing the header would definitely be the wrong thing.
> On Fri, Jul 1, 2016 at 5:34 PM, Richard Smith <richard at metafoo.co.uk>
> wrote:
>
>> On Fri, Jul 1, 2016 at 4:22 PM, Eric Fiselier via cfe-commits <
>> cfe-commits at lists.llvm.org> wrote:
>>
>>> Author: ericwf
>>> Date: Fri Jul 1 18:22:25 2016
>>> New Revision: 274403
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=274403&view=rev
>>> Log:
>>> Work around ABI break caused by C++17 inline variables.
>>>
>>> Modified:
>>> libcxx/trunk/src/chrono.cpp
>>>
>>> Modified: libcxx/trunk/src/chrono.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=274403&r1=274402&r2=274403&view=diff
>>>
>>> ==============================================================================
>>> --- libcxx/trunk/src/chrono.cpp (original)
>>> +++ libcxx/trunk/src/chrono.cpp Fri Jul 1 18:22:25 2016
>>> @@ -6,7 +6,7 @@
>>> // Source Licenses. See LICENSE.TXT for details.
>>> //
>>>
>>> //===----------------------------------------------------------------------===//
>>> -
>>> +#define _LIBCPP_BUILDING_CHRONO
>>> #include "chrono"
>>> #include "cerrno" // errno
>>> #include "system_error" // __throw_system_error
>>> @@ -32,6 +32,9 @@ namespace chrono
>>> // system_clock
>>>
>>> const bool system_clock::is_steady;
>>>
>>
>> Can you mark this as __attribute__((used)) instead of adding a separate
>> use?
>>
>>
>>> +// Make is_steady non-discardable in C++17
>>> +// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395)
>>> +static const bool& __is_steady_force_use1 __attribute__((used)) =
>>> system_clock::is_steady;
>>>
>>> system_clock::time_point
>>> system_clock::now() _NOEXCEPT
>>> @@ -68,6 +71,10 @@ system_clock::from_time_t(time_t t) _NOE
>>> // instead.
>>>
>>> const bool steady_clock::is_steady;
>>> +// Make is_steady non-discardable in C++17
>>> +// See PR28395 (https://llvm.org/bugs/show_bug.cgi?id=28395)
>>> +static const bool& __is_steady_force_use2 __attribute__((used)) =
>>> steady_clock::is_steady;
>>> +
>>>
>>> #ifdef CLOCK_MONOTONIC
>>>
>>>
>>>
>>> _______________________________________________
>>> cfe-commits mailing list
>>> cfe-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160701/8ab0f172/attachment-0001.html>
More information about the cfe-commits
mailing list