public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libphobos: Handle Darwin Arm and AArch64 in fibre context asm.
@ 2023-07-02 10:22 Iain Sandoe
  2023-07-02 10:50 ` Iain Buclaw
  0 siblings, 1 reply; 2+ messages in thread
From: Iain Sandoe @ 2023-07-02 10:22 UTC (permalink / raw)
  To: gcc-patches; +Cc: ibuclaw

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 <iain@sandoe.co.uk>

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)
-- 
2.39.2 (Apple Git-143)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libphobos: Handle Darwin Arm and AArch64 in fibre context asm.
  2023-07-02 10:22 [PATCH] libphobos: Handle Darwin Arm and AArch64 in fibre context asm Iain Sandoe
@ 2023-07-02 10:50 ` Iain Buclaw
  0 siblings, 0 replies; 2+ messages in thread
From: Iain Buclaw @ 2023-07-02 10:50 UTC (permalink / raw)
  To: gcc-patches, iain

Excerpts from Iain Sandoe's message of Juli 2, 2023 12:22 pm:
> 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 <iain@sandoe.co.uk>
> 

OK.

Thanks!
Iain.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-02 10:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-02 10:22 [PATCH] libphobos: Handle Darwin Arm and AArch64 in fibre context asm Iain Sandoe
2023-07-02 10:50 ` Iain Buclaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).