From patchwork Thu Jan 20 12:31:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 50277 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 57BD93857C48 for ; Thu, 20 Jan 2022 12:33:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 57BD93857C48 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1642681983; bh=K30nHj7+JWp8WRi3yx4lX2cztDmci8aYtflLHsK1Prc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Bv/1SwiGaredmN3gFsCKlm9bYFHbqfJbruopKbE6HBHlenDP8Es0ac7McrxzyPAM7 pknZncGjtHxG1FZIa5iQHqkt6CESOvmVWzWa1zxPB3NzA0lRZ0lXpjuWAxZvNEIvIr OaJoDfKCN+5NchnnyRHrSklj+TZ8ao1qnUCzC8o8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 C45BC385781D for ; Thu, 20 Jan 2022 12:32:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C45BC385781D Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-202-ArUD4w7VPt2WaEA6E7mlUA-1; Thu, 20 Jan 2022 07:31:58 -0500 X-MC-Unique: ArUD4w7VPt2WaEA6E7mlUA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B4601006AA6; Thu, 20 Jan 2022 12:31:57 +0000 (UTC) Received: from localhost (unknown [10.33.37.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id E29171F453; Thu, 20 Jan 2022 12:31:56 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Use Clang attribute instead of __constinit Date: Thu, 20 Jan 2022 12:31:55 +0000 Message-Id: <20220120123155.34827-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Tested powerpc64le-linux, pushed to trunk. Clang doesn't support the __constinit extension that we use pre-C++20, but it does have its own equivalent attribute that can be used instead. This makes it a little easier to use Clang to build libstdc++ (which isn't supported. but is sometimes attempted for esoteric targets). libstdc++-v3/ChangeLog: * src/c++11/cxx11-ios_failure.cc (__constinit): Define as equivalent attribute for Clang. * src/c++11/future.cc (__constinit): Likewise. * src/c++11/system_error.cc (__constinit): Likewise. * src/c++17/memory_resource.cc (__constinit): Likewise. --- libstdc++-v3/src/c++11/cxx11-ios_failure.cc | 4 ++++ libstdc++-v3/src/c++11/future.cc | 4 ++++ libstdc++-v3/src/c++11/system_error.cc | 4 ++++ libstdc++-v3/src/c++17/memory_resource.cc | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/libstdc++-v3/src/c++11/cxx11-ios_failure.cc b/libstdc++-v3/src/c++11/cxx11-ios_failure.cc index ba4b1413bf9..14a7f9cfcb1 100644 --- a/libstdc++-v3/src/c++11/cxx11-ios_failure.cc +++ b/libstdc++-v3/src/c++11/cxx11-ios_failure.cc @@ -42,6 +42,10 @@ # error This file should not be compiled for this configuration. #endif +#if __has_cpp_attribute(clang::require_constant_initialization) +# define __constinit [[clang::require_constant_initialization]] +#endif + namespace { struct io_error_category final : std::error_category diff --git a/libstdc++-v3/src/c++11/future.cc b/libstdc++-v3/src/c++11/future.cc index 488ff17a1e6..c52c057ba1d 100644 --- a/libstdc++-v3/src/c++11/future.cc +++ b/libstdc++-v3/src/c++11/future.cc @@ -25,6 +25,10 @@ #include #include +#if __has_cpp_attribute(clang::require_constant_initialization) +# define __constinit [[clang::require_constant_initialization]] +#endif + namespace { struct future_error_category final : public std::error_category diff --git a/libstdc++-v3/src/c++11/system_error.cc b/libstdc++-v3/src/c++11/system_error.cc index 789f2b45382..7b1a5a20637 100644 --- a/libstdc++-v3/src/c++11/system_error.cc +++ b/libstdc++-v3/src/c++11/system_error.cc @@ -37,6 +37,10 @@ #include #endif +#if __has_cpp_attribute(clang::require_constant_initialization) +# define __constinit [[clang::require_constant_initialization]] +#endif + namespace { using std::string; diff --git a/libstdc++-v3/src/c++17/memory_resource.cc b/libstdc++-v3/src/c++17/memory_resource.cc index 5cdb35df2cd..bb6334c9694 100644 --- a/libstdc++-v3/src/c++17/memory_resource.cc +++ b/libstdc++-v3/src/c++17/memory_resource.cc @@ -32,6 +32,10 @@ # include // std::__exchange #endif +#if __has_cpp_attribute(clang::require_constant_initialization) +# define __constinit [[clang::require_constant_initialization]] +#endif + namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION