Skip to content

macOS (Apple Silicon) support #51

Closed

Description

@aotodev

First feature after v0.1.0; becomes 0.2.0. Apple Silicon (arm64) only: x86_64
macOS is not claimed, and the reactor, fuzzing and TSan stay Linux-only.
Depends on the assembly macro issue (#) so the .S files already carry the
Mach-O branch.

Already in place: arch normalisation (arm64 -> aarch64, freestanding only on
arm), make.sh accepts Darwin and detects a native build, the ASan gate is
the CFIBER_ASAN_ENABLED build define with a __has_feature mismatch check,
cfiber_init zeroes the context, and the growable-stack test already catches
SIGBUS (what macOS raises on the guard page). No local macOS machine: parts
below are proven by the GitHub job, expect a few CI round trips.

A. Growable stacks on Darwin

  • MAP_STACK is undefined on macOS: define it to 0 when missing. MAP_NORESERVE
    exists and is ignored.
  • MADV_DONTNEED does not drop resident pages on Darwin; use MADV_FREE_REUSABLE
    (or MADV_FREE) under APPLE in cfiber_growable_stack_recycle.
  • 16 KiB pages: guard page and growth granularity are four times larger. Code
    and tests already use sysconf(_SC_PAGESIZE); document, do not special-case.
    One Darwin sentence in the overcommit paragraph of docs/memory.md.

B. Build and script

  • C23 constexpr needs Apple Clang 17 (Xcode 16.3+) or Homebrew LLVM. If the
    runner's Xcode is too old: brew install llvm, CC pointed at it, and a line
    in docs/building.md.
  • CFIBER_BUILD_SHARED yields libcfiber.dylib with SOVERSION; confirm install +
    find_package consumer once (DYLD_LIBRARY_PATH).
  • make.sh: drop "(macOS is unverified)" from the host check once CI runs.
    timeout is only needed for QEMU, so native runs need no coreutils.
  • Apple arm64 ABI: x18 reserved and never touched; frame pointers mandatory,
    a fresh fiber starts with x29 = 0; 16-byte alignment already holds. Listed
    so the port does not re-check them.

C. CI and docs

  • .github/workflows/macos.yml on macos-15 (arm64), no container: make.sh -t -e and -t -e -d, then --asan and --shared once green. Same paths:
    filter and timeout-minutes as the other workflows; README badge.
  • README platform table row: macOS arm64 | AAPCS64 (Apple) | Native (GitHub macos-15 runner); adjust "No other host is supported".
  • docs/building.md requirements; docs/memory.md Darwin notes.
  • CHANGELOG Unreleased -> 0.2.0 and project(cfiber VERSION 0.2.0) in the tag
    preparation PR.

Check

  • Linux matrix unchanged.
  • macOS job green: register set and FP control, return hook, allocators,
    scheduler, fixed and growable stacks including the guard-page fault, death
    tests, scheduler example.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions