Repository navigation
Conversation
New ports under src/port/aarch64/macos and src/port/x86-64/macos: - Context switch: AArch64 assembly saving X19-X30, D8-D15, FPCR/FPSR, and a Mach-O (macho64) variant of the x86-64 NASM switch. - Guarded coroutine stacks via posix_memalign + mprotect, main stack bounds from pthread_get_stackaddr_np / pthread_get_stacksize_np. - Seeds from arc4random_buf, core count from sysconf. Shared changes, all limited to the new platforms: - cmi_config.h recognises arm64 and macOS. - Trial recovery uses setjmp/longjmp on arm64, since Clang does not implement __builtin_setjmp on AArch64. - Build: dispatch to the new ports, only require NASM on x86-64, use _DARWIN_C_SOURCE instead of _POSIX_C_SOURCE on macOS, and only pass -ffat-lto-objects when the compiler accepts it (Apple Clang does not). Co-Authored-By: Claude <noreply@anthropic.com> Includes-AI-Code: true
Context switch shares the arm64 macOS frame layout (X19-X30, D8-D15,
FPCR/FPSR) in ELF form. Stack allocation keeps the Linux per-thread pool
of recycled guarded stacks and pthread_getattr_np main stack bounds.
Seeds come from getrandom(), page size, aligned allocation and core
count reuse the x86-64 Linux sources.
initial-exec TLS sets DF_STATIC_TLS, and glibc on aarch64 refuses to
dlopen such a library late in the process ("cannot allocate memory in
static TLS block"), which breaks loading it from Python. Keep
initial-exec on x86-64 Linux only; arm64 uses TLS descriptors.
Distribution GCCs enable _FORTIFY_SOURCE, which turns longjmp into
__longjmp_chk. That check aborts ("longjmp causes uninitialized stack
frame") when an abandoned trial jumps from a coroutine stack back to
the worker stack, so it is disabled for cimba.c on arm64 Linux.
Co-Authored-By: Claude <noreply@anthropic.com>
Includes-AI-Code: true
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for arm64 (AArch64) Linux.
New port:
src/port/aarch64/linuxpthread_getattr_np.getrandom(), falling back to the thread id, the clock andcntvct_el0.Shared changes
initial-execis now used on x86-64 Linux only, in bothmeson.buildandCMB_THREAD_LOCAL. On aarch64, glibc refuses todlopena library marked as using static TLS late in the process ("cannot allocate memory in static TLS block"), which breaks loading Cimba from Python. The default TLS descriptor model is cheap on arm64._FORTIFY_SOURCE. Turned off incimba.con arm64 Linux. Distribution GCCs turn it on by default, which makeslongjmpgo through__longjmp_chk. That check aborts ("longjmp causes uninitialized stack frame") when an abandoned trial jumps from a coroutine stack back to the worker stack. x86-64 is unaffected because it uses__builtin_longjmp.Testing
Not run as part of preparing this PR, since I have no arm64 Linux machine here. Checked so far: the assembly builds for
aarch64-linux-gnuand exports the expected symbols, and the macOS tests still pass with this branch. The port comes from a fork where it has been in use. Runningmeson teston an arm64 Linux machine before merging would be good.Tested on AWS arm64 boxes.
Co-Authored-By: Claude noreply@anthropic.com
Includes-AI-Code: true