[RFA/C] Reimplementation of std::call_once.

Iain Sandoe iain@sandoe.co.uk
Wed Aug 9 13:12:43 GMT 2023



> On 9 Aug 2023, at 13:53, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> 
> On Wed, 9 Aug 2023 at 13:51, Iain Sandoe <iain@sandoe.co.uk> wrote:
>> 
>>> On 9 Aug 2023, at 13:38, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>>> 
>>> On Wed, 9 Aug 2023 at 13:22, Iain Sandoe <iain@sandoe.co.uk> wrote:
>>>> =====
>>>> the implementation in mutex.cc can sit togethe with the old version so that the symbols for that remain available (or, for versioned libraries, the old code can be deleted).
>>> 
>>> If you have old and new code sharing a std::once_flag object you're dead.
>> 
>> indeed - I was only considering the case where existing binaries needed to run with the new lib, not the case where code compiled with two different impls was combined.
>> 
>>> Something like the abi_tag transition for std::string in GCC 5 would be needed.
>> 
>> That sounds quite complicated and likely to produce similar pain?
> 
> Not nearly as complicated (since we don't use std::call_once
> throughout the entire library) but it would still cause pain for the
> ecosystem.

I was, at one stage, considering the idea of [the new impl] copying the trampoline lambda address to the (old) => __once_call and the closure address to (old) __once_callable and then amending __once_proxy to handle this.

It would still be broken w.r.t. nested call_once cases, but no more broken than existing.

However, that means lying about the signature of the old __once_call.

.. and it does not solve the issue that the size of the once_flag has changed.

>> ====
>> 
>> Presumably an alternative is that I just have to accept that Darwin needs to use a versioned library (which is a direction I am close to heading in because of co-existence of mulitple c++ runtimes anyway).
> 
> We do need to fix PR 99341 somehow, I just don't know how.

yeah, tricky.

that PR shows as closed, FWIW - but as noted at the start I think x86_64-linux-gnu is also broken w.r.t once-called fns throwing

Iain



More information about the Libstdc++ mailing list