Support cross-building the OCaml toolchain on macOS - #14
Open
samoht wants to merge 1 commit into
Open
Conversation
Closed
samoht
marked this pull request as draft
July 7, 2026 00:19
samoht
marked this pull request as ready for review
July 7, 2026 01:26
On a macOS host, targeting aarch64-linux is a cross build the arch check misses: the host and target arch are both aarch64, only the OS differs, so CROSS_COMPILE must be set explicitly to the <arch>-linux-gnu- prefix that Linux auto-selects. The messense/macos-cross-toolchains Homebrew tap provides that toolchain, so conf-<arch>-linux-gnu-gcc resolves on macOS too. Patch Makefile.cross so crossopt does not pass -function-sections to the host .opt tools (the macOS host ocamlopt is Mach-O and rejects it), keeping it for the target library; mark the packages available on macOS. Rewrite the crossopt version check without `case` inside `$(...)`, which macOS's bash 3.2 mis-parses (it reads the `)` in `5.5.*)` as closing the substitution).
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.
I'd like to cross-build Unikraft OCaml unikernels on an Apple Silicon Mac.
On a macOS host, targeting
aarch64-linuxis a cross build the arch check misses: host and target arch are both aarch64, only the OS differs, so the build falls back to the host compiler unlessCROSS_COMPILEis set. This sets it for{os = "macos"}to the same<arch>-linux-gnu-prefix Linux auto-selects. Themessense/macos-cross-toolchainsHomebrew tap provides that full toolchain (gcc and binutils underaarch64-linux-gnu-*), so the existingconf-<arch>-linux-gnu-gccdependency resolves on macOS too, with no divergent triple or gating.It also passes
--disable-function-sectionsto the OCaml configure on macOS, since crossopt's ocamlopt is built without function-sections support, and marks the packages available on macOS.The same
--disable-function-sectionsfinding drives the macOS support in the sibling ocaml-solo5 backend (mirage/ocaml-solo5#171).