Skip to content

unix: support building Linux x86-64 from macOS aarch64#1179

Merged
jjhelmus merged 5 commits into
mainfrom
jjh/gps-macos-linux-x86-64-cross-compile
Jul 23, 2026
Merged

unix: support building Linux x86-64 from macOS aarch64#1179
jjhelmus merged 5 commits into
mainfrom
jjh/gps-macos-linux-x86-64-cross-compile

Conversation

@jjhelmus

Copy link
Copy Markdown
Contributor

Update to #1056 to use docker buildx for reliable handeling of the platform argument.

indygreg and others added 4 commits July 21, 2026 10:04
Docker on aarch64 macOS will automagically virtualize x86-64 containers
if containers are spawned with `platform=linux/amd64`. Performance of
spawned containers is a bit slower than native, but not horrible. This
functionality means it is viable to develop Linux x86-64 from modern
Apple hardware.

This commit teaches the build system to support cross-compiling
Linux x86-64 from macOS aarch64.

Implementing this wasn't too difficult: we need to pass `platform` into
Docker's APIs for building and creating containers. We need to teach
code to resolve the effective host platform when this scenario is
detected. And we need to advertise support for cross-compiling in the
`targets.yml` file.

In case you are wondering, yes, a similar solution could be employed for
Linux too by using emulation. But this requires Docker be configured to
support emulation, which isn't common. Rosetta on macOS "just works" and
is therefore the lowest hanging fruit to implement.
Subprocess out to docker buildx to build images. The api.build function
does not support BuildKit and always uses the legacy builder. To
properly support the platform argument BuildKit must be used.
@jjhelmus
jjhelmus force-pushed the jjh/gps-macos-linux-x86-64-cross-compile branch from edcbdce to 26e740d Compare July 21, 2026 15:05
@jjhelmus jjhelmus added platform:linux Specific to the Linux platform platform:all Select all platforms, e.g., darwin, linux, windows build:all python:all Select all Python versions labels Jul 23, 2026
@jjhelmus
jjhelmus merged commit c1991f8 into main Jul 23, 2026
130 checks passed
@jjhelmus
jjhelmus deleted the jjh/gps-macos-linux-x86-64-cross-compile branch July 23, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build:all platform:all Select all platforms, e.g., darwin, linux, windows platform:linux Specific to the Linux platform python:all Select all Python versions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants