Skip to content

Add experimental Apple Silicon native target and reproducible app setup - #16

Closed
pkyanam wants to merge 2 commits into
OpenCommunityEdition:mainfrom
pkyanam:apple-silicon-native
Closed

pkyanam wants to merge 2 commits into
OpenCommunityEdition:mainfrom
pkyanam:apple-silicon-native

Conversation

@pkyanam

@pkyanam pkyanam commented Sep 29, 2026

Copy link
Copy Markdown

Adds an experimental Apple Silicon native target alongside the existing platforms, with a small README platform entry and focused build documentation.

port/macos/setup.sh /path/to/Halo.iso builds from the current checkout, including indexed working changes. It never fetches an older copy of this repository or reapplies the standalone Mac patch over current source. The isolated build fetches pinned translator/musl prerequisites, compiles and lifts the guest, builds the native SDL/OpenGL/audio/POSIX bridge, then packages an ad-hoc signed application with bundle-relative libraries and user-provided maps/movies. Writable profiles, configuration and caches stay outside sealed game data. No game downloads, game assets or generated translation are included in the PR.

The target includes the native symbol collision guard, Darwin connected-UDP compatibility, translated errno propagation, controller adapters and F10 cycling between 4:3, 720p and 1080p. Existing upstream CC0 and vendor notices remain intact; MIT applies to original Mac tooling/glue as scoped by the added notices.

Validation: public pinned-source preparation, complete final guest compilation, 12,010 translated functions with no failures/unresolved direct targets, native POSIX/UDP and translated XInput/errno fixtures, and static signed self-contained packaging passed locally. Actual macOS 26 app acceptance covered relocation, the full intro/audio, persistent display cycling and clean Command-Q. Campaign opening-scene smoke checks and two same-host multiplayer instances on Blood Gulch/Battle Creek were exercised. The standalone GitHub fixture workflow is green; its complete installer workflow is still running at submission. This PR adds synthetic-disc CI without downloading or launching game content.

Kept as a draft because older macOS versions, physical controllers, full mission completion, cross-platform networking and large player counts remain unverified. Native source targets macOS 14; each produced bundle computes the actual minimum required by its engine and libraries.

Standalone tooling and validation scope: https://github.com/pkyanam/halo-ce-apple-silicon

damiantw referenced this pull request in damiantw/halo-ce-web-multiplayer Sep 30, 2026
Web: multiplayer only, no menus; player color; leave back to the site
@MrMilenko MrMilenko added enhancement New feature or request priority: low Nice to have / when time allows labels Oct 5, 2026
@cybersecurity

Copy link
Copy Markdown
Collaborator

macOS support cannot be officially added due to the github runners for them costing 10x as much as Linux runners (I also don't own any apple products so I cannot do testing). Long term, I will likely link one of the MacOS / IOS forks in the main repo for people to find.

startupfoundry referenced this pull request in OpenH1/goath1 Oct 15, 2026
The guest (ILP32 AArch64 code, port/android/README.md) uses its 32-bit
pointers as addresses, so Linux and Android keep its memory in the low 4 GB.
macOS on Apple silicon gives no process the low 4 GB. With --base-register,
tools/android_asm_convert.py now also rewrites the guest's assembly
(tools/guest_base_register.py) so that its 4 GB can lie at any base aligned
to 4 GB, as LFI rewrites AArch64 code into a sandbox:

- x21 holds the base and x22 is a scratch register (-ffixed-x21 -ffixed-x22);
- each load and store through a general register adds the base to the
  register's low 32 bits: [x21, wN, uxtw], which costs no more than [xN],
  after an offset is added in 32 bits (add w22, wN, #8), as LFI does; the
  instructions without that form (ldp, exclusives, SIMD structures) add
  the base into x22 first;
- sp and x29 hold full addresses and are left alone, as are globals'
  accesses through their adrp page; an address taken from sp, x29 or a page
  is computed in 32 bits (add w0, wsp, #16), since arm64_32 code expects
  the upper half of a pointer register to be zero (a pointer argument
  widened to 64 bits compiles to nothing);
- sp or x29 set from another register is rebased; indirect branches go to
  the base plus the target;
- anything else that touches memory is an error of the build.

Jump tables are full width with the base register (the compressed ones'
byte offsets overflow once instructions are added). The import stubs
(tools/android_imports.py, from the prototypes in guest_host.h) and the
generated posix and OpenGL wrappers give the host its pointer arguments as
host addresses; the OpenGL arguments that are offsets into a bound buffer
pass as they are. Without the option nothing changes: the generated stubs
and the build graphs of the Android and Linux arm64 builds are as before.

Checked with tools/test_guest_base_register.py (each form of the rewrite,
what it refuses, a compiled function, the stubs), and by building the whole
guest image so (the game, musl, the platform layer, the libraries): no
instruction is left that the rewrite does not know.
Adam-AtlasSoftware pushed a commit to Adam-AtlasSoftware/MendicantCE that referenced this pull request Nov 12, 2026
…queue

Wake every waiter of a futex requeue on macOS
Adam-AtlasSoftware pushed a commit to Adam-AtlasSoftware/MendicantCE that referenced this pull request Nov 12, 2026
- futex REQUEUE and CMP_REQUEUE wake every waiter on the first address,
  as OpenCommunityEdition#16 does on macOS: musl's broadcast hand-on (unlock_requeue: wake 0,
  move 1) left the moved waiter asleep for good.
- A descriptor that is not open is EBADF: the C runtime's descriptor
  calls (_get_osfhandle, _close, _dup, _dup2, and win32_files.c's
  _lseeki64 and _chsize_s) run with a thread-local invalid-parameter
  handler that does nothing, where the global one reports a crash.
- pread and pwrite go through a second handle of the file (ReOpenFile,
  made the first time, kept with the descriptor), whose own position
  they move: the descriptor's position, which read, write and lseek
  share, is never saved and restored around them, so other threads'
  reads see it as they left it. A pipe or console is ESPIPE.
- lseek(fd, 0, SEEK_SET) of a directory (rewinddir) starts its listing
  again.
- ppoll with nothing to wait for and no timeout blocks, rather than
  spinning on Sleep(0); a pipe's write end is POLLOUT (PeekNamedPipe
  cannot read it, which was taken for POLLHUP).
- Joinable host threads are a list whose entry is made before the
  thread, so every one can be joined (the table of 64 dropped handles).
- The launcher's copy shares halo.log: both open it shared for writing,
  each line added at the end, and the copy keeps the launcher's lines.
- HALO_WINDOWS_LAUNCHED is set in the copy's environment alone (its
  value the launcher's process id), read once at the top of main and
  taken out of the environment, so no later process (the self-updater's
  restart) takes itself for a launched copy; the copy takes over only a
  reservation that is exactly the launcher's (one allocation of the
  range's size, reserved, PAGE_NOACCESS). host_launched and its variable
  are host_win.h's, once.
- Windows before 10 is told plainly that the game needs Windows 10 1903
  or later; 10 before 1903 is logged (no UTF-8 code page). The
  no-Vulkan box says older graphics cards and virtual machines may have
  no Vulkan 1.3.
- The FILETIME conversions are host_posix_win.c's alone.

Not run on Windows. Checked: every host file compiles (syntax only)
with mingw-w64's headers, the host's objects leave no symbol of their
own unresolved, ninja macos and ninja windows_guest.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request priority: low Nice to have / when time allows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants