From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id 9E1EB3858D20 for ; Wed, 9 Aug 2023 12:53:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9E1EB3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-99bc512526cso980393966b.1 for ; Wed, 09 Aug 2023 05:53:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691585611; x=1692190411; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Qbj+8x/947DBiJWmowUpkQLnBxRwyPfHReetVkfP4ys=; b=k3vNGTs7t0zapEFKlqXRF2XO5M0caexNlCkTJe4zwDp+FbmZE/5L0Hp+VrFEtMGWaX GucQK7McDpTm8d8w+k1vLq+RFSqmDX8i8PIFBEgS+u7roHsg/8As6LF8v1O/YAm+li8k de5y+36IPReH5AXa9Xo9HsmQlA3zzhI88SwB/CRPma7P7C2XaAbQ+48VtIwhp1mkFkNC avqNGR5u1dAmZfQGRjAIuLXBtYKchecrcOHcf929IngBroQWECXFSqSYUxVNb32qdL9r IUZUBkz+vsbuBmUqgi3xJ+xzHv+CVslai7cipsKSL7RJ9UkTsuWwD7IrrlfikUHgN6xy N3Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691585611; x=1692190411; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Qbj+8x/947DBiJWmowUpkQLnBxRwyPfHReetVkfP4ys=; b=Du4Xvc4/GR3UOBYrtUz5MmZyiAnDZ8MVSs/g3jDQx+EjkODKfFPGO8CKk1RzGQop7j nLxRnZXn4lX1h2axgfU3v+eA6RRLlPWvn1E4tiNV39RnkbXvSeDQ518dqhnqUz9/sO3W YR2oS2CjMrppiicF1qZm8w3NJMT8WBZPKEW6l5hEuamI8G27NNU9FWYCYwkyxsR178qU SFEW/FpF2tzrVF5PbfR+eodAqCQWsCeMtO/aq9qnzqvnwDUlqMzKekwsH8JH06RTBwzP MDw0H81Zstzf7CyqvZ8MBht1taFeYWhi9fTuijqN8H82QrHBW442kIW5JRbBOGWzmIiL Dwsw== X-Gm-Message-State: AOJu0Yx0y3B5zr+QIRhpirjLS1H0JtJL+x1i/x7pG8MP3s+xF9sLZOHT fYapRvMwJJ4M1amQ/UBnqVXWlK5nBtj6Ui1/XsI= X-Google-Smtp-Source: AGHT+IHzU2c1+f3mar5V1ajUC2T6piaceWSBQwpAvnlTEQx2Mbq+3c2vhhoiiKSaVgIdoePjgcoDjlAnB2swtHI7AuY= X-Received: by 2002:a17:906:10c:b0:999:80cf:82fd with SMTP id 12-20020a170906010c00b0099980cf82fdmr2227956eje.18.1691585611127; Wed, 09 Aug 2023 05:53:31 -0700 (PDT) MIME-Version: 1.0 References: <0B281969-EB24-405E-B41A-83429CDDA8FE@sandoe.co.uk> In-Reply-To: <0B281969-EB24-405E-B41A-83429CDDA8FE@sandoe.co.uk> From: Jonathan Wakely Date: Wed, 9 Aug 2023 13:53:20 +0100 Message-ID: Subject: Re: [RFA/C] Reimplementation of std::call_once. To: Iain Sandoe Cc: libstdc++@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, 9 Aug 2023 at 13:51, Iain Sandoe wrote: > > Hi Jonathan, > > > On 9 Aug 2023, at 13:38, Jonathan Wakely wrote: > > > > On Wed, 9 Aug 2023 at 13:22, Iain Sandoe wrote: > >> > >> Hello. > >> > >> With the current [posix-y] implementation of std::call_once, we are se= eing significant issues for Darwin. The issues vary in strength from =E2=80= =9Changs or segvs sometimes depending on optimisation and the day of the we= ek=E2=80=9D (newer OS, faster h/w) to =E2=80=9Csegvs or std::terminates eve= ry time=E2=80=9D older OS slower h/w. > >> > >> Actually, I think that in the presence of exceptions it is not working= on Linux either. > >> > >> As a use-case: this problem prevents us from building working LLVM/cla= ng tools on Darwin using GCC as the bootstrap compiler. > >> > >> the test code I am using is: https://godbolt.org/z/Mxcnv9YEx (derived = from a cppreference example, IIRC). > >> > > >> This is a prototype, so I=E2=80=99m looking for advice/comment on: > >> > >> (a) if this can be generalised to be part of libstdc++ > >> (b) what that would take ... > >> (c) ..or if I should figure out how to make this a darwin-specific imp= l. > > > > > > It's an ABI break. I already tried to replace std::call_once once, see > > r11-4691-g93e79ed391b9c6 and r11-7688-g6ee24638ed0ad5 and PR 99341. > > blast. > > >> =E2=80=94=E2=80=94 here is the prototype implementation as a non-patc= h .. (patch attached). > >> > > >> =3D=3D=3D=3D=3D > >> the implementation in mutex.cc can sit togethe with the old version so= that the symbols for that remain available (or, for versioned libraries, t= he old code can be deleted). > > > > If you have old and new code sharing a std::once_flag object you're dea= d. > > indeed - I was only considering the case where existing binaries needed t= o 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. > > =3D=3D=3D=3D > > 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.