Skip to content

support building the aarch64 cross-compiler on macOS - #168

Closed
samoht wants to merge 5 commits into
mirage:mainfrom
samoht:macos-cross-build
Closed

support building the aarch64 cross-compiler on macOS#168
samoht wants to merge 5 commits into
mirage:mainfrom
samoht:macos-cross-build

Conversation

@samoht

@samoht samoht commented Jun 18, 2026

Copy link
Copy Markdown
Member

I'd like to build aarch64 Solo5/MirageOS unikernels on an Apple Silicon Mac, instead of going through a Linux VM. This package is the OCaml cross-compiler for that target.

This PR builds it with the macOS LLVM toolchain: it passes the toolchain ar/ranlib to the nolibc and openlibm makes, adds the matching cross OCaml configure flags, drops the native solo5 dependency (no macOS build), and marks macos/arm64 available. The generated aarch64-solo5-ocaml-* wrappers also resolve their tools to absolute paths, so they work off PATH.

The rest of the stack:

@samoht
samoht marked this pull request as draft June 18, 2026 19:56
@samoht
samoht force-pushed the macos-cross-build branch 4 times, most recently from f97ad05 to 26f3acf Compare June 20, 2026 22:07
@samoht
samoht force-pushed the macos-cross-build branch 4 times, most recently from bfc2a5c to df639b7 Compare June 21, 2026 05:13
@samoht
samoht marked this pull request as ready for review June 22, 2026 16:37
samoht added 2 commits June 22, 2026 09:39
Pass AR and RANLIB to the nolibc and openlibm sub-makes so they use the
toolchain archiver (llvm-ar/ranlib) instead of the host default, and add
-Wno-asm-operand-widths to the nolibc CFLAGS for clang. On macOS, build the
cross OCaml with --othertoolprefix=llvm-, --enable-imprecise-c99-float-ops and
--disable-function-sections, drop the native solo5 dependency (which has no
macOS build), and mark macos/arm64 as an available platform.
The generated aarch64-solo5-ocaml-<tool> wrappers exec'd the bare tool name
(e.g. llvm-ar via --othertoolprefix), so they only worked when that tool's
directory was on PATH. On macOS the LLVM binutils live outside the Solo5
toolchain and the opam switch, so a plain `dune build -x` failed to find them.
Bake the absolute path that command -v already returns.
@samoht
samoht force-pushed the macos-cross-build branch 2 times, most recently from b8be574 to fb145a9 Compare June 23, 2026 00:02
samoht added 2 commits June 23, 2026 11:30
Build the aarch64 cross-compiler (pinning Solo5/solo5#641) and cross-build
zarith with it: install ocaml-gmp (mirage/ocaml-gmp#29) for its relocatable
gmp.pc, then point OCAMLC/OCAMLOPT/... at `ocamlfind -toolchain solo5` and
PKG_CONFIG_PATH at that gmp.pc so zarith's configure (ocaml/Zarith#173) compiles
caml_z.c with the cross cc against ocaml-gmp. Drop this commit, or the pins,
once the forks are in opam.
@samoht
samoht force-pushed the macos-cross-build branch 2 times, most recently from c4e986b to 49be517 Compare June 26, 2026 05:29
The second alternative was missing its operator: {= "5.4.1" | "5.5.0"}
makes opam read "5.5.0" as a bare filter (warning 66). Use
{= "5.4.1" | = "5.5.0"}, as ocaml-solo5.opam already does.
@samoht

samoht commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

Superseded by #171 — the same macOS cross-compiler support, rebuilt cleanly (two focused commits, libgcc-free, verified end-to-end by a full cross build). Closing in favour of #171.

@samoht samoht closed this Jul 6, 2026
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.

1 participant