From patchwork Tue Apr 26 15:02:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1622445 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=sQ2dWBYH; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KnlgH1qg4z9s0B for ; Wed, 27 Apr 2022 01:10:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B51FA3858403 for ; Tue, 26 Apr 2022 15:10:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B51FA3858403 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1650985815; bh=R8lGSh1s/hCHshuEU+VcwCcZJtmA7rjCICMH0tz+JNE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=sQ2dWBYH/lv1QJSEHGbewW8ZRuP/RK/cO6AmsO6Oi6dBmBoJUW+OJ5f2pFK0fGnD9 A/jGDs1wgwnkV4QjIGQSUwoiRrgtopc4xRCzwwg8JLldHtw5wcSHzP4W5bgf9/Zg/V 6oJBGi1GHOZoessMDCEYQ+8EyNSnlFUA79w6unAg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by sourceware.org (Postfix) with ESMTPS id 0F7713858C83 for ; Tue, 26 Apr 2022 15:09:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0F7713858C83 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4Knlfh16ZYz9smZ; Tue, 26 Apr 2022 17:09:48 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [GCC 11 backport][committed] libphobos: Give _Unwind_Exception an alignment that best resembles __attribute__((aligned)) Date: Tue, 26 Apr 2022 16:02:40 +0100 Message-Id: <20220426150240.3138494-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This patch backports r12-3986 to the GCC 11 branch. For interoperability with C++ EH, the alignment should match, otherwise D may not be able to intercept exceptions thrown from C++. Bootstrapped and regression tested on x86_64-apple-darwin20. Regards, Iain. --- libphobos/ChangeLog: * libdruntime/gcc/unwind/generic.d (__aligned__): Define. (_Unwind_Exception): Align struct to __aligned__. --- libphobos/libdruntime/gcc/unwind/generic.d | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/libphobos/libdruntime/gcc/unwind/generic.d b/libphobos/libdruntime/gcc/unwind/generic.d index 592b3afcb71..68ddd1d5410 100644 --- a/libphobos/libdruntime/gcc/unwind/generic.d +++ b/libphobos/libdruntime/gcc/unwind/generic.d @@ -123,7 +123,27 @@ enum : _Unwind_Reason_Code // @@@ The IA-64 ABI says that this structure must be double-word aligned. // Taking that literally does not make much sense generically. Instead we // provide the maximum alignment required by any type for the machine. -struct _Unwind_Exception + version (ARM) private enum __aligned__ = 8; +else version (AArch64) private enum __aligned__ = 16; +else version (HPPA) private enum __aligned__ = 8; +else version (HPPA64) private enum __aligned__ = 16; +else version (MIPS_N32) private enum __aligned__ = 16; +else version (MIPS_N64) private enum __aligned__ = 16; +else version (MIPS32) private enum __aligned__ = 8; +else version (MIPS64) private enum __aligned__ = 8; +else version (PPC) private enum __aligned__ = 16; +else version (PPC64) private enum __aligned__ = 16; +else version (RISCV32) private enum __aligned__ = 16; +else version (RISCV64) private enum __aligned__ = 16; +else version (S390) private enum __aligned__ = 8; +else version (SPARC) private enum __aligned__ = 8; +else version (SPARC64) private enum __aligned__ = 16; +else version (SystemZ) private enum __aligned__ = 8; +else version (X86) private enum __aligned__ = 16; +else version (X86_64) private enum __aligned__ = 16; +else static assert( false, "Platform not supported."); + +align(__aligned__) struct _Unwind_Exception { _Unwind_Exception_Class exception_class; _Unwind_Exception_Cleanup_Fn exception_cleanup;