From patchwork Sun Jul 2 10:22:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 115079 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp11482380vqr; Sun, 2 Jul 2023 03:23:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlHCsTtf507GGNgweYxeWN0rARY+KgxtSv6rXYsQ7Nc7mhN7v5zjAr75IOiYUPDG7qsCTjSd X-Received: by 2002:a50:ec8c:0:b0:51d:9dd1:29d0 with SMTP id e12-20020a50ec8c000000b0051d9dd129d0mr5290419edr.23.1688293410027; Sun, 02 Jul 2023 03:23:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688293410; cv=none; d=google.com; s=arc-20160816; b=zNmqk7lCKUWDVAckcy4HOZP3NfHR/4TbSUDTz/WDExYahyDCnIFHGkadWdaUkdlx70 YB8G6rV8KgwtWGWvZwVtOZcQQB/6GRJxVE5AppAotpsju5IzcSR3KJ+Ng1jeBUO4PONJ XgYsIVntZhi1DSgKw2tw80VML2AhZjBkzZMEkhijrXnqc4BLCfM+pc7KBzuIKBHacjVZ yEwoGK5FyBhdFpLZqZPMdybKX8SKSXNojtUOwxLo25u2VBVCOp+P0kmBZmoTyF1tjCe0 +q/WEyjygLmCA1tnuO5RhCS1WZLC5Ga55e9Nb//7blzAp9H+e1PRw5ERrILvbWJKTULu eY5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=IhoYCVsY1LDkRcw1tEWoYXd4Gcm2QJTZ/Vhqkc3KxLs=; fh=IqFqX21ZYZvPsb39ftrqkkWZzOle5Q+eqk1B+nfPW08=; b=xhl8hBeqsogamYhEYfrZ4k3y6STLkaS1TyEldbBIChlPAdUDTPFwEP6YazFhc0amoH Hl7yn6o5DL1Wjp75OBZBl+F7yKojWK94AxZiMd2hC+PNqNccPFSgQp99EWwj6sp73Wez mo+VRygoVdxbjxDUXOnx1vNmRFkrPrFs5i8xxrE2v3b78KNACFrTJosXvGLAPbdAun4x Y802Tkyg8YZtqhBqGbiT2EZ1fbUHVtujLr6qxfsKo4g1oRQTrxaQJyf0cHGHIx7HPKEQ /3EE8fL9Ij4aLKhnPiRQXz77IphEdmXso39pvhVHZnLbRWDWQGw4rcU0qj0rMt6aNc6n 5now== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=t0lfaIOl; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id u16-20020a056402065000b0051dec0e4eccsi3059012edx.47.2023.07.02.03.23.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jul 2023 03:23:30 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=t0lfaIOl; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B693F385843E for ; Sun, 2 Jul 2023 10:23:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B693F385843E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688293408; bh=IhoYCVsY1LDkRcw1tEWoYXd4Gcm2QJTZ/Vhqkc3KxLs=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=t0lfaIOlWVy49bZ73LV+LnzUkWcP+MfbElCFZ6N4m7lvJPywgKVntEk2yqCmIHYBo NGOXe121HR5Hog1KzQRJE4IblEmWmS8k/w5AFLX2ru/VgVTuSsdOT2KN/TJdM/mH0L pQmpUtJEs7lO7dbW+RE/E+c1x4xes/VmQElvPZ+I= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id 73E473858412 for ; Sun, 2 Jul 2023 10:22:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 73E473858412 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fbca8935bfso17824245e9.3 for ; Sun, 02 Jul 2023 03:22:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688293364; x=1690885364; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=IhoYCVsY1LDkRcw1tEWoYXd4Gcm2QJTZ/Vhqkc3KxLs=; b=aIRqLgP9Ri2MbOgWtRbEKtqTLwPgl54B6hQbJU75w3TdGCBmVvi+QGzPcyU0CtAevH Y1IAtAr55tnf/CfyISAwl3r2oGY/7KlB1R5s4WCg1E6z6UgY2N56mb/GOeuvsdZu2PjG KsPomkX3rhoO29t5Dhl5IaZ5VYjSlipiGqiO7jWBqDnsirORZIUTau32bRc8B/lLneCv fLdSrso7RAE3vksOZxEtgOboNufRDn/GdAucZnBZ7q9eXw4A+QEcChhHENKFjILQsG5E 0D3GOAwORRhDnb1HPSpUXRyvFknrjG1cSBaArlVljyh3y/VZ/Ad+pwoGdewiPR5RveAl dCMg== X-Gm-Message-State: AC+VfDz7jbMT9kafUU0nKVWKLOfIIxydGDc1b96d/2PR9VdgnKVVSnts YYvXtBoOV2mjTyusW/BnulF8k7/denPsMg== X-Received: by 2002:a05:600c:21c9:b0:3fb:40ec:9483 with SMTP id x9-20020a05600c21c900b003fb40ec9483mr5508191wmj.16.1688293363845; Sun, 02 Jul 2023 03:22:43 -0700 (PDT) Received: from localhost.localdomain (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.gmail.com with ESMTPSA id p5-20020a5d68c5000000b00314283a525bsm4471954wrw.93.2023.07.02.03.22.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 02 Jul 2023 03:22:43 -0700 (PDT) X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Subject: [PATCH] libphobos: Handle Darwin Arm and AArch64 in fibre context asm. Date: Sun, 2 Jul 2023 11:22:42 +0100 Message-Id: <20230702102242.56435-1-iain@sandoe.co.uk> X-Mailer: git-send-email 2.39.2 (Apple Git-143) MIME-Version: 1.0 X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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: 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 Sandoe via Gcc-patches From: Iain Sandoe Reply-To: iain@sandoe.co.uk Cc: Iain Sandoe , ibuclaw@gdcproject.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770303950488253117?= X-GMAIL-MSGID: =?utf-8?q?1770303950488253117?= Tested on AArch64 (Arm64) Darwin on 11.x, 13.x and master, OK for trunk? and backports? thanks Iain --- 8< --- This code currently fails to build because it contains ELF- specific directives. This patch excludes those directives when the platform is Darwin. We do not expect switching fibres between threads to be safe here either owing to the possible caching of TLS pointers. Signed-off-by: Iain Sandoe libphobos/ChangeLog: * libdruntime/config/aarch64/switchcontext.S: Exclude ELF- specific constructs for Darwin. * libdruntime/config/arm/switchcontext.S: Likewise. * libdruntime/core/thread/fiber.d: Disable switching fibres between threads. --- libphobos/libdruntime/config/aarch64/switchcontext.S | 9 ++++++++- libphobos/libdruntime/config/arm/switchcontext.S | 8 ++++++++ libphobos/libdruntime/core/thread/fiber.d | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libphobos/libdruntime/config/aarch64/switchcontext.S b/libphobos/libdruntime/config/aarch64/switchcontext.S index 5cfa2f698e8..d3bd646bc56 100644 --- a/libphobos/libdruntime/config/aarch64/switchcontext.S +++ b/libphobos/libdruntime/config/aarch64/switchcontext.S @@ -44,7 +44,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see */ .text .global CSYM(fiber_switchContext) +#ifndef __APPLE__ .type CSYM(fiber_switchContext), %function +#endif .align 4 CSYM(fiber_switchContext): .cfi_startproc @@ -77,8 +79,9 @@ CSYM(fiber_switchContext): ldp d15, d14, [sp], #20*8 ret .cfi_endproc +#ifndef __APPLE__ .size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext) - +#endif /** * When generating any kind of backtrace (gdb, exception handling) for * a function called in a Fiber, we need to tell the unwinder to stop @@ -93,11 +96,15 @@ CSYM(fiber_switchContext): .text .global CSYM(fiber_trampoline) .p2align 2 +#ifndef __APPLE__ .type CSYM(fiber_trampoline), %function +#endif CSYM(fiber_trampoline): .cfi_startproc .cfi_undefined x30 // fiber_entryPoint never returns bl CSYM(fiber_entryPoint) .cfi_endproc +#ifndef __APPLE__ .size CSYM(fiber_trampoline),.-CSYM(fiber_trampoline) +#endif diff --git a/libphobos/libdruntime/config/arm/switchcontext.S b/libphobos/libdruntime/config/arm/switchcontext.S index 3f9b35e7334..f1f2060fd97 100644 --- a/libphobos/libdruntime/config/arm/switchcontext.S +++ b/libphobos/libdruntime/config/arm/switchcontext.S @@ -60,11 +60,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see */ .text +#ifndef __APPLE__ #if defined(__ARM_PCS_VFP) || (defined(__ARM_PCS) && !defined(__SOFTFP__)) .fpu vfp #endif .global CSYM(fiber_switchContext) .type CSYM(fiber_switchContext), %function +#else + .global CSYM(fiber_switchContext) +#endif .align 4 CSYM(fiber_switchContext): .cfi_sections .debug_frame @@ -111,8 +115,12 @@ CSYM(fiber_switchContext): mov lr, #0 // return by writing lr into pc mov pc, r1 +#ifndef __APPLE__ .fnend .cfi_endproc .size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext) +#else + .cfi_endproc +#endif #endif diff --git a/libphobos/libdruntime/core/thread/fiber.d b/libphobos/libdruntime/core/thread/fiber.d index 4590ff1c052..66fb9dad89d 100644 --- a/libphobos/libdruntime/core/thread/fiber.d +++ b/libphobos/libdruntime/core/thread/fiber.d @@ -1785,6 +1785,7 @@ version (OSX) { version (X86) version = UnsafeFiberMigration; version (X86_64) version = UnsafeFiberMigration; + version (AArch64) version = UnsafeFiberMigration; } version (UnsafeFiberMigration)