Skip to content

macos: build and run Ceph natively on Apple silicon - #71889

Open
dvanders wants to merge 7 commits into
ceph:mainfrom
dvanders:wip-macos-7-macos
Open

dvanders wants to merge 7 commits into
ceph:mainfrom
dvanders:wip-macos-7-macos

Conversation

@dvanders

Copy link
Copy Markdown
Contributor

The last of the seven PRs #71232 was split into. Based on main and
mergeable on its own, but it is the one that only means something with
the other six in: #71883, #71884, #71885, #71886, #71887, #71888.

The goal is a local vstart cluster on a MacBook, so Ceph development can
happen there without a Linux VM. With the full series the client
libraries, the mon, the OSD (memstore only), the mgr, the MDS, the RGW and
the offline tools build with Apple clang, and vstart.sh --memstore
brings all five daemons up. RADOS, RBD, S3 and CephFS through ceph-fuse
all work against it. BlueStore is out of scope: it needs libaio or
io_uring and the Linux block layer.

What is here:

  • arch/arm.c: probe the ARM CPU features through sysctl on Darwin,
    which has no getauxval — this is what actually enables hardware crc32c
    and NEON gf-complete once cmake: recognise AppleClang and arm64 #71887 has cmake recognising arm64
  • FindFUSE.cmake and client/fuse_ll.cc: build ceph-fuse against
    macFUSE, which ships the vanilla libfuse3 API rather than the old
    Darwin-specific one the __APPLE__ branches assumed
  • do_cmake_macos.sh: a configure helper, companion to do_freebsd.sh
  • doc/dev/macos.rst: rewritten. The page still described a 2018 build —
    a brew clang because Xcode's was too old for C++17, hand-written paths
    into /usr/local/Cellar, and the conclusion that FUSE and librados
    applications were the practical uses. None of that holds.

The doc covers the dependencies, the submodules that must not be cloned
shallow, the extra packages the mgr, the MDS and the RGW each want, and
the handful of Darwin behaviours that read as bugs the first time: a full
memstore looking like a hang, mgr commands hanging when no mgr is running,
and radosgw aborting in the Objective-C runtime because it forks without
exec.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)

🤖 Generated with Claude Code

@dvanders

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@dvanders

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

dvanders added a commit to dvanders/ceph that referenced this pull request Oct 1, 2026
Apple's toolchain reports CMAKE_SYSTEM_PROCESSOR as "arm64", which does
not match the "aarch64|AARCH64" arm of SIMDExt.cmake but does match the
"arm|ARM" arm that follows it, since MATCHES is an unanchored regex.
Apple silicon therefore took the 32 bit ARM path: HAVE_ARM came out
right, but the only feature test run was -mfpu=neon, which Apple clang
rejects for a 64 bit target.  Everything gated on the ARMv8 results
stayed off, so on Darwin/arm64:

* crc32c_aarch64.c was never compiled and crc32c fell back to the
  portable sctp table, at 1263 MB/s against 7383 MB/s for the CRC32
  instructions,
* gf-complete was built without ARM_NEON, so jerasure and shec used the
  table based GF arithmetic,
* WITH_EC_ISA_PLUGIN, which keys off HAVE_ARMV8_SIMD, stayed off, so
  there was no ISA-L erasure code plugin at all,
* the zlib compressor was built without the ISA-L igzip sources.

Add arm64 to the ARMv8 arm of SIMDExt.cmake, and to the ARM test in
BuildISAL.cmake that adds the assembler flag the SVE sources need.

This alone builds crc32c_aarch64.c but does not select it on Darwin:
ceph_arch_aarch64_crc32 stays 0, and crc32c keeps using sctp, until
"arch/arm: probe the ARM CPU features through sysctl on Darwin" (ceph#71889)
also lands.  The 7383 MB/s above needs both.
The SVE code stays dead on Apple silicon, which has no SVE: ISA-L's
aarch64 dispatchers already special case __APPLE__ and return the NEON
implementations there, having no getauxval() to ask.

Deliberately not touched are the WITH_SPDK and WITH_UADK conditions,
which also spell only aarch64.  Both are Linux only for other reasons.

Verified on Darwin arm64 with the unit tests for crc32c, compression
and every erasure code plugin, and on a vstart memstore cluster with an
ISA-L k=2 m=1 pool: a 32 MiB object read back byte identical both with
the full acting set and with one shard's OSD stopped.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
@dvanders dvanders mentioned this pull request Oct 1, 2026
4 of 14 tasks
Comment thread qa/standalone/ceph-helpers.sh Resolved
dvanders added a commit to dvanders/ceph that referenced this pull request Oct 9, 2026
Apple's toolchain reports CMAKE_SYSTEM_PROCESSOR as "arm64", which does
not match the "aarch64|AARCH64" arm of SIMDExt.cmake but does match the
"arm|ARM" arm that follows it, since MATCHES is an unanchored regex.
Apple silicon therefore took the 32 bit ARM path: HAVE_ARM came out
right, but the only feature test run was -mfpu=neon, which Apple clang
rejects for a 64 bit target.  Everything gated on the ARMv8 results
stayed off, so on Darwin/arm64:

* crc32c_aarch64.c was never compiled and crc32c fell back to the
  portable sctp table, at 1263 MB/s against 7383 MB/s for the CRC32
  instructions,
* gf-complete was built without ARM_NEON, so jerasure and shec used the
  table based GF arithmetic,
* WITH_EC_ISA_PLUGIN, which keys off HAVE_ARMV8_SIMD, stayed off, so
  there was no ISA-L erasure code plugin at all,
* the zlib compressor was built without the ISA-L igzip sources.

Add arm64 to the ARMv8 arm of SIMDExt.cmake, and to the ARM test in
BuildISAL.cmake that adds the assembler flag the SVE sources need.

This alone builds crc32c_aarch64.c but does not select it on Darwin:
ceph_arch_aarch64_crc32 stays 0, and crc32c keeps using sctp, until
"arch/arm: probe the ARM CPU features through sysctl on Darwin" (ceph#71889)
also lands.  The 7383 MB/s above needs both.
The SVE code stays dead on Apple silicon, which has no SVE: ISA-L's
aarch64 dispatchers already special case __APPLE__ and return the NEON
implementations there, having no getauxval() to ask.

Deliberately not touched are the WITH_SPDK and WITH_UADK conditions,
which also spell only aarch64.  Both are Linux only for other reasons.

Verified on Darwin arm64 with the unit tests for crc32c, compression
and every erasure code plugin, and on a vstart memstore cluster with an
ISA-L k=2 m=1 pool: a 32 MiB object read back byte identical both with
the full acting set and with one shard's OSD stopped.

Assisted-by: claude-code:claude-opus-5
Signed-off-by: Dan van der Ster <[email protected]>
@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

ceph_arch_arm_probe() reads the ELF auxiliary vector, so its whole body
is under #if __linux__ and every flag it exports stays zero elsewhere.
On Darwin that silently disabled the accelerated paths that the flags
guard even though the hardware has them: crc32c.cc kept the portable
implementation, and the zlib plugin's factory refused ISA-L because it
asks for ceph_arch_aarch64_pmull && ceph_arch_neon.

Darwin has no getauxval(3); the kernel publishes the optional CPU
features as sysctl(3) nodes instead, so read them from there.  A node
the running kernel does not register reads back as an error, which is
the answer we want for a feature that is not there.

On this M-series machine the probe now reports neon, crc32 and pmull,
crc32c dispatches to ceph_crc32c_aarch64 - 7383 MB/s against 1263 MB/s
for the sctp fallback in unittest_crc32c - and unittest_compression
exercises the zlib plugin as "zlib/isal" rather than skipping it.

Assisted-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Dan van der Ster <[email protected]>
macFUSE installs libfuse2 and libfuse3 side by side, in
/usr/local/include/fuse and /usr/local/include/fuse3, and adds a
compatibility shim at /usr/local/include/fuse.h whose entire content is

  #include "fuse/fuse.h"

so a bare <fuse.h> resolves to libfuse2.  Apple clang searches
/usr/local/include ahead of every -isystem directory, and CMake hands
an imported target's include directories over as -isystem, so the
libfuse3 directory can never win that lookup.  ceph_fuse.h then gets
the libfuse2 declarations while fuse_ll.cc's own <fuse_lowlevel.h>
gets the libfuse3 ones, and the two disagree about every shared type:

  /usr/local/include/fuse3/fuse_opt.h:77:8: error: redefinition of 'fuse_opt'
  /usr/local/include/fuse/fuse_opt.h:76:8: note: previous definition is here

Marking the target IMPORTED_NO_SYSTEM emits -I instead, which is
searched before /usr/local/include and picks the intended version.  The
property needs CMake 3.23; on anything older it is ignored and such a
build has to point FUSE_INCLUDE_DIR at a single version by hand.

Assisted-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Dan van der Ster <[email protected]>
macFUSE's libfuse3 defaults FUSE_DARWIN_ENABLE_EXTENSIONS to 1, which
routes the declarations through FUSE_DARWIN_EXTEND_FUNCTION and
FUSE_DARWIN_EXTEND_OPERATION and hands back the Darwin flavour of the
API: fuse_reply_entry() takes a fuse_darwin_entry_param, fuse_reply_attr()
a fuse_darwin_attr, and the xattr operations carry an extra uint32_t
position.  fuse_ll.cc is written against upstream libfuse3, so every one
of those call sites fails to compile.

Ask for the vanilla API instead, before fuse_common.h applies its
default.  Ceph uses none of the Darwin extensions - no birth time, no
backup time, no setvolname - so nothing is given up.

That leaves the position argument on fuse_ll_setxattr() and
fuse_ll_getxattr(), which has been guarded by a bare __APPLE__ since the
osxfuse days.  It belongs to the FUSE 2 API, where macFUSE declares it
under a plain #ifdef __APPLE__ with no way to opt out, and it must not
appear against vanilla libfuse3.  Qualify the guard with the version so
both libraries build.

Verified on macOS 26.6 with macFUSE 5.3.3 (libfuse 3.18.2) against a
vstart memstore cluster: ceph-fuse mounts file system 'a', and read,
write, mkdir, rename, truncate, chmod, symlink, hard link, statfs and
clean unmount all behave.  A 64 MiB file round trips to the same
sha256, arriving as 18 objects in the data pool, and the xattr paths
touched here answer for both user xattrs and the ceph.* virtual ones.

Assisted-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Dan van der Ster <[email protected]>
Companion to do_freebsd.sh.  Points cmake at the keg-only homebrew packages,
selects the virtualenv interpreter that carries Cython, and disables what
either cannot build on Darwin or wants dependencies beyond the base set.

The mon, the OSD on memstore, the client libraries, libcephsqlite and the
offline tools are on.  The mgr, the MDS and the RGW are off, not because
they fail to build - they do build, and run - but because each needs
packages the base set does not pull in; doc/dev/macos.rst covers those.
BlueStore is off because it needs libaio or io_uring and the Linux block
layer.

Assisted-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Dan van der Ster <[email protected]>
The page still described a 2018 build: a brew-installed clang because
Xcode's was too old for C++17, hand-written paths into /usr/local/Cellar
with pinned nss and openssl versions, and the conclusion that FUSE and
librados applications were the practical uses.

None of that holds.  The Apple clang from the Command Line Tools builds
the tree, do_cmake_macos.sh replaces the hand-written cmake line, and a
vstart cluster runs the mon, the OSD, the mgr, the MDS and the RGW
together on memstore, with RADOS, RBD, CephFS through ceph-fuse and S3 all
working against it.  The ARM accelerated paths - hardware crc32c, NEON
gf-complete and the ISA-L erasure code plugin - are picked up too.

Rewrite around what someone actually has to do: the dependencies, the
submodules that must not be cloned shallow, the extra packages and options
the mgr, the MDS and the RGW each want, how to mount CephFS with
ceph-fuse, and the handful of Darwin behaviours that read as bugs the
first time - a full memstore looking like a hang, mgr commands hanging
when no mgr is running, and radosgw aborting in the Objective-C runtime
because it forks without exec.

Build the optional daemons with WITH_SYSTEM_BOOST=OFF rather than
homebrew's boost-python3.  The separate formula is built against whichever
[email protected] it pins, and Ceph would then have to embed that same
interpreter; letting Ceph build Boost itself keeps the choice of python in
the reader's hands and needs no extra package.

Say plainly what is out of scope: BlueStore needs libaio or io_uring and
the Linux block layer, so memstore is the object store here.

Assisted-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Dan van der Ster <[email protected]>
A build on a clean Mac stops at configure for want of dependencies the
page never listed: lua for cls_lua, which builds everywhere but Windows;
pkgconf, which Findsnappy requires; and the src/isa-l submodule, which
WITH_EC_ISA_PLUGIN turns on by itself on arm64.  With the submodule
present, isal_ext-configure then fails without autoconf, automake and
libtool, because ISA-L is built with its autogen.sh.  uv was used but
never installed.

Add them to the brew line and the submodule list, and have
do_cmake_macos.sh check for the submodule and the autotools up front:
the errors CMake and the ExternalProject give for them do not name the
cause.  Also set pipefail, so that a failed cmake is not hidden by the
tee into cmake.log.

Document the tapi error a mismatched SDK and Command Line Tools linker
gives on the first compiler check.

Assisted-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Dan van der Ster <[email protected]>
Two changes on main since the guide was written:

- src/pybind stops when Python and Ceph link different OpenSSL versions.
  The Python that uv downloads brings its own (3.5 against Homebrew's
  openssl@3 3.6), so build the venv on Homebrew's [email protected].
- WITH_RADOSGW_LANCEDB is on by default on arm64 and needs cargo 1.91 or
  later; turn it off with the other optional RGW parts.

Reported-by: Bryan Stillwell <[email protected]>
Assisted-By: Claude Opus 5.5 (1M context) <[email protected]>
Signed-off-by: Dan van der Ster <[email protected]>
@dvanders
dvanders requested a review from a team as a code owner November 13, 2026 01:09
@dvanders

Copy link
Copy Markdown
Contributor Author

Rebased on main. Dropped 'qa/standalone: make calc() work with any POSIX awk': #72822 merged the same fix. The other commits are unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants