libphobos: Handle Darwin Arm and AArch64 in fibre context asm.

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.
This commit is contained in:
Iain Sandoe 2023-07-02 11:14:08 +01:00
parent 2e06e39a12
commit 6757bf8614
3 changed files with 17 additions and 1 deletions

View File

@ -44,7 +44,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
*/ */
.text .text
.global CSYM(fiber_switchContext) .global CSYM(fiber_switchContext)
#ifndef __APPLE__
.type CSYM(fiber_switchContext), %function .type CSYM(fiber_switchContext), %function
#endif
.align 4 .align 4
CSYM(fiber_switchContext): CSYM(fiber_switchContext):
.cfi_startproc .cfi_startproc
@ -77,8 +79,9 @@ CSYM(fiber_switchContext):
ldp d15, d14, [sp], #20*8 ldp d15, d14, [sp], #20*8
ret ret
.cfi_endproc .cfi_endproc
#ifndef __APPLE__
.size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext) .size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext)
#endif
/** /**
* When generating any kind of backtrace (gdb, exception handling) for * When generating any kind of backtrace (gdb, exception handling) for
* a function called in a Fiber, we need to tell the unwinder to stop * a function called in a Fiber, we need to tell the unwinder to stop
@ -93,11 +96,15 @@ CSYM(fiber_switchContext):
.text .text
.global CSYM(fiber_trampoline) .global CSYM(fiber_trampoline)
.p2align 2 .p2align 2
#ifndef __APPLE__
.type CSYM(fiber_trampoline), %function .type CSYM(fiber_trampoline), %function
#endif
CSYM(fiber_trampoline): CSYM(fiber_trampoline):
.cfi_startproc .cfi_startproc
.cfi_undefined x30 .cfi_undefined x30
// fiber_entryPoint never returns // fiber_entryPoint never returns
bl CSYM(fiber_entryPoint) bl CSYM(fiber_entryPoint)
.cfi_endproc .cfi_endproc
#ifndef __APPLE__
.size CSYM(fiber_trampoline),.-CSYM(fiber_trampoline) .size CSYM(fiber_trampoline),.-CSYM(fiber_trampoline)
#endif

View File

@ -60,11 +60,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
*/ */
.text .text
#ifndef __APPLE__
#if defined(__ARM_PCS_VFP) || (defined(__ARM_PCS) && !defined(__SOFTFP__)) #if defined(__ARM_PCS_VFP) || (defined(__ARM_PCS) && !defined(__SOFTFP__))
.fpu vfp .fpu vfp
#endif #endif
.global CSYM(fiber_switchContext) .global CSYM(fiber_switchContext)
.type CSYM(fiber_switchContext), %function .type CSYM(fiber_switchContext), %function
#else
.global CSYM(fiber_switchContext)
#endif
.align 4 .align 4
CSYM(fiber_switchContext): CSYM(fiber_switchContext):
.cfi_sections .debug_frame .cfi_sections .debug_frame
@ -111,8 +115,12 @@ CSYM(fiber_switchContext):
mov lr, #0 mov lr, #0
// return by writing lr into pc // return by writing lr into pc
mov pc, r1 mov pc, r1
#ifndef __APPLE__
.fnend .fnend
.cfi_endproc .cfi_endproc
.size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext) .size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext)
#else
.cfi_endproc
#endif
#endif #endif

View File

@ -1785,6 +1785,7 @@ version (OSX)
{ {
version (X86) version = UnsafeFiberMigration; version (X86) version = UnsafeFiberMigration;
version (X86_64) version = UnsafeFiberMigration; version (X86_64) version = UnsafeFiberMigration;
version (AArch64) version = UnsafeFiberMigration;
} }
version (UnsafeFiberMigration) version (UnsafeFiberMigration)