Skip to content

Extend macOS portability layer for Apple Silicon#9070

Closed
yeabat8tcap wants to merge 3947 commits intofiredancer-io:macos-integrationfrom
yeabat8tcap:feature-macos-to-integration-apple
Closed

Extend macOS portability layer for Apple Silicon#9070
yeabat8tcap wants to merge 3947 commits intofiredancer-io:macos-integrationfrom
yeabat8tcap:feature-macos-to-integration-apple

Conversation

@yeabat8tcap
Copy link
Copy Markdown

This PR merges the Apple Silicon (M-series) portability layer from the firedancer-apple fork into the macos-integration branch. It includes:

  • NUMA shims for macOS.
  • Thread QoS/Priority handling via Mach APIs.
  • Randomized shared memory mapping (fixed for Mach).
  • accept4 shims and other socket handling fixes.

riptl and others added 30 commits March 6, 2026 13:52
Fixes a bug that results in unrelated fork graph nodes getting
dropped on accdb_cancel.
…o#8763)

* bundle: fix STEM_BURST by buffering transactions in a deque

unit tests

zero copy design

more hardening

* tile

* PR comments

* use stem abstraction

* PR comments

* remove stale metrics

* remove stack copies

* add tests

* plumb bundle topology depth
Reduce git diff churn when reordering metrics by deriving metric
indices using an enum
…cer-io#8782)

* runtime: fix missing serialization and address in builtin-to-core-bpf migration

new_target_program_account() constructs an UpgradeableLoaderState::Program
state but never serializes it into acc->data, leaving the account with
all-zero data after migration. The sister function
new_target_program_data_account() correctly calls
fd_bpf_upgradeable_loader_state_encode(). In Agave, AccountSharedData::new_data()
handles both allocation and serialization atomically.

Additionally, the call site in migrate_builtin_to_core_bpf1() never sets
new_target_program->addr to the builtin program address, so
tmp_account_store() writes the account to an uninitialized address.
Agave stores to target.program_address explicitly.

Add the encode call in new_target_program_account() and set the address
at the call site.

* add missing addr assignment

* flamenco, bpf migration: implement verified_build_hash check

* flamenco, bpf migration: fix logic for when buffer has authority but config doesn't specify one

* fixup

* flamenco, ledger: add enshrine_slashing_program ledger

* flamenco, bpf migration: add discriminant check

---------

Co-authored-by: nlgripto <155116201+nlgripto@users.noreply.github.com>
get_token_to_eol prevents oob read, but would still except numeric prefixes -- and is just wrong usage
the write in fd_runtime_pre_execute_check makes more sense, also given early returns
topointon-jump and others added 25 commits March 26, 2026 10:04
* stakes: eliminate O(n_delegations) loop in fd_stakes_activate_epoch
* firedancer: clean up vote_keyed_lsched and chacha20

* firedancer: clean up switch_to_chacha8_turbine from codebase

---------

Co-authored-by: Emanuele Cesena <ecesena@jumptrading.com>
This commit implements a comprehensive portability layer to enable native Firedancer builds on macOS ARM64. Key changes include:
- Core Libraries: Successfully compiled libfd_util, libfd_ballet, libfd_tango, libfd_flamenco, and libfd_disco on macOS.
- Shared Memory: Replaced Linux hugepages with mlock-backed anonymous memory via shm_open(SHM_ANON).
- Threading: Implemented Mach thread priority (QoS) and affinity shims for fd_tile.
- Agave Integration: Patched x86_64 rdtsc intrinsics for ARM64 and resolved RocksDB linkage issues.
- System Shims: Implemented getrandom-to-getentropy, clock_nanosleep, and networking shims (mmsghdr, recvmmsg).
- SANDBOX & SECCOMP: Stubbed Linux-specific process isolation and security features for macOS compatibility.
- Type Compatibility: Resolved global ulong vs uint64_t pointer mismatches and type-generic overflow built-ins.
- Build System: Introduced apple_silicon.mk and updated Local.mk rules for Darwin targets.

Work in progress: Finalizing fdctl linkage and verifying Gossiping/RPC.
@ripatel-fd
Copy link
Copy Markdown
Contributor

Thank you for the contribution. This is a bit too big too review or merge (600K lines of changes), but I'd be happy to accept a series of PRs with smaller changes. For example, the first PR could just add #if defined(__linux__) guards.
Several components can be skipped entirely: It doesn't make sense to make the seccomp-generated files portable because seccomp itself is Linux specific.
Similarly, there's no point in adding NUMA support for macOS because there are no modern macOS systems that support multiple sockets.

@ripatel-fd ripatel-fd closed this Mar 30, 2026
@ripatel-fd
Copy link
Copy Markdown
Contributor

For this kind of contribution specifically, we cannot accept LLM-generated patches, because of the asymmetric human review cost.

@yeabat8tcap
Copy link
Copy Markdown
Author

Ahh I see, okay. Is it better to create a separate branch and cherry pick from there? I can be able to do that. Let me know, thanks. @ripatel-fd

@ripatel-fd
Copy link
Copy Markdown
Contributor

Ahh I see, okay. Is it better to create a separate branch and cherry pick from there? I can be able to do that. Let me know, thanks. @ripatel-fd

Yes that would be great, thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.