From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id A64D73856DC5 for ; Thu, 14 Jul 2022 15:25:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A64D73856DC5 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-534-cizY0kTRObS_K5WsA5ePhA-1; Thu, 14 Jul 2022 11:25:35 -0400 X-MC-Unique: cizY0kTRObS_K5WsA5ePhA-1 Received: by mail-qv1-f71.google.com with SMTP id q3-20020ad45743000000b004735457f428so1420757qvx.23 for ; Thu, 14 Jul 2022 08:25:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=n9GHCardaGiarhzYXvWtgnMagauImn1AksV2tNEqGhs=; b=nmkCX+kJ6aV6jPvykiPV+js5THpkNUX27COObCNsp018hhk398LAkoumtwCOjAQIGj +kk2uev13oqQm870UQLtWVbx55U0Q4PqTxwGc6kkmvwrP3MwnfMxOnDbViG09VGiqf2i dnykG1sTbIqPvIuZkWbRX7zO96gmmaTS1UlrRSGS5H/M4QyaPDgxHbTUbeXnOTyy6NH6 FWN5npKh7ZD0329ZKrU/K2oq7R7RBSuLno65QvZ9EAtY3hCaAJW2LcLRNLN7+yFfytjv W2R29kq+3nVG1ju3CgW2PVFCNnS+gNJopeOcV+sVVB7mjYM+3PG3X34uBz/qohcjgDLq S9ug== X-Gm-Message-State: AJIora88AcroGSUo0coSquyX4wKuDJabAL1f28/0fq0GB7INY2yEJN0G QfcZ5xOnT/17dAgh5dR8ScksAuM89+0WRkJnqGgaUVaelNGgBwGUJw1eFxc1Gu9FL05tZ8uCObu edCazmhNDJwFJI0R2ACpx0e78Pe4FKVQ= X-Received: by 2002:a05:620a:46a1:b0:6af:3bc3:dd89 with SMTP id bq33-20020a05620a46a100b006af3bc3dd89mr6419742qkb.18.1657812335043; Thu, 14 Jul 2022 08:25:35 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tyJ+t3VJLmsac/Zi6YWSrulIjpfxsJGTT/GmJyquJDZQRWX5ghiJh03L/7tZmknieRL07omT9kO6/rDoz6htg= X-Received: by 2002:a05:620a:46a1:b0:6af:3bc3:dd89 with SMTP id bq33-20020a05620a46a100b006af3bc3dd89mr6419665qkb.18.1657812333849; Thu, 14 Jul 2022 08:25:33 -0700 (PDT) MIME-Version: 1.0 References: <87a69bgba0.fsf@euler.schwinge.homeip.net> In-Reply-To: <87a69bgba0.fsf@euler.schwinge.homeip.net> From: Jonathan Wakely Date: Thu, 14 Jul 2022 16:25:22 +0100 Message-ID: Subject: Re: libstdc++ "freestanding" ('--disable-hosted-libstdcxx') with '-fno-rtti', '-fno-exceptions': 'libstdc++-v3/libsupc++/eh_alloc.cc' global constructors To: Thomas Schwinge Cc: libstdc++@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="00000000000043bfb305e3c58329" X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jul 2022 15:25:44 -0000 --00000000000043bfb305e3c58329 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, 14 Jul 2022 at 15:53, Thomas Schwinge wrote: > > Hi! > > In context of '[OpenMP][AMDGCN][nvptx] > C++ offloading: unresolved _Znwm =3D "operator new(unsigned long)"' > I'm looking into building GCN, nvptx offloading libstdc++ "freestanding" > ('--disable-hosted-libstdcxx') with '-fno-rtti', '-fno-exceptions'. > (I've basically got these things wired up; details to be shared later.) > > For nvptx, I'm running into: > > In function =E2=80=98(static initializers for [...]/libstdc++-v3/libs= upc++/eh_alloc.cc)=E2=80=99: > cc1plus: sorry, unimplemented: global constructors not supported on t= his target > make[4]: *** [Makefile:777: eh_alloc.lo] Error 1 > > ... because, indeed, "global constructors not supported" for nvptx at > this time. This may change, but I'd first like to get clarified > conceptually to which extent 'libstdc++-v3/libsupc++/eh_alloc.cc' is > actually relevant for such a libstdc++ configuration, It depends. Does your target *ever* support exceptions? Building libstdc++ with -fno-exceptions means that the library code can't throw or catch exceptions, but in theory user code linking to that libstdc++ build could still be compiled with -fexceptions. In such a scenario, the __cxxabiv1::__cxa_allocate_exception and __cxxabiv1::__cxa_free_exception functions (which are required by the C++ ABI) are still needed. But if your target completely disallows -fexceptions, you probably don't need anything in that file. > and/or whether this > should be expected to compile fine already? I think a few people have built libstdc++ with -fno-rtti and -fno-exceptions recently, and that should work. The problem here is the lack of global ctors, which is much less common. You might find other parts of libstdc++ that don't build for the same reason, although maybe those other parts are all disabled for freestanding builds. > Do certain things simply > need to be '#if'-conditionalized, or similar, for example? Yes, I think so. > I've not yet > looked into the details; hoping that's maybe easy for you to answer? Does the attached patch work? --00000000000043bfb305e3c58329 Content-Type: text/plain; charset="US-ASCII"; name="patch.txt" Content-Disposition: attachment; filename="patch.txt" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_l5l6jy890 ZGlmZiAtLWdpdCBhL2xpYnN0ZGMrKy12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