Skip to content

build: cross compile the macOS x86_64 target natively on Apple Silicon - #296

Merged
devopvoid merged 1 commit into
ci/macos-x86_64-ffmpeg-cachefrom
build/macos-x86_64-native-cross
Sep 27, 2026
Merged

devopvoid merged 1 commit into
ci/macos-x86_64-ffmpeg-cachefrom
build/macos-x86_64-native-cross

Conversation

@devopvoid

Copy link
Copy Markdown
Owner

Stacked on #295.

The Intel macOS build already ran on an Apple Silicon runner (macos-14), but all of it under Rosetta: an x64 JDK, and every Maven call behind arch -x86_64, so CMake, clang, gn, ninja and FFmpeg's configure and make were all emulated.

Maven now runs natively and cross compiles:

  • The root pom gains a macos-cross-x86_64 profile that sets the macos-x86_64 classifier. It is declared after macos-aarch64, which the host still activates, so its properties win.
  • The media module takes webrtc-jni's x86_64-macos-cross.cmake toolchain, so FFmpeg is configured as a cross build (--enable-cross-compile, x86 asm kept, assembled by nasm). Apple's strip reads Mach-O of any architecture, so stripping stays on for macOS.
  • The CI actions build with an arm64 JDK and run only the tests on an x64 JDK (under Rosetta), which is what loading the Intel natives needs.

Checked locally with the OS faked as an arm64 Mac (MAVEN_OPTS="-Dos.name=Mac_OS_X -Dos.arch=aarch64"): with -Pmacos-cross-x86_64 the classifier resolves to macos-x86_64, both native modules pick up the cross toolchain, and FFmpeg installs into ~/ffmpeg/macos-x86_64. Not yet run on macOS.

Test plan

  • macOS x86_64 job builds, and file on the packaged dylibs reports x86_64
  • Tests pass on the x64 JDK
  • FFmpeg rebuild (cache miss) succeeds in cross mode
  • Build time compared against the Rosetta build on main
  • Optionally, a WebRTC cache miss to confirm gn builds x64 on an arm64 host

The Intel macOS build already ran on an Apple Silicon runner, but all of it
under Rosetta: an x64 JDK, and every Maven call behind arch -x86_64, so
CMake, clang, gn, ninja and FFmpeg's configure and make were all emulated.

Maven now runs natively and cross compiles:
- the root pom gains a macos-cross-x86_64 profile that sets the macos-x86_64
  classifier, declared after macos-aarch64, which the host still activates
- the media module takes webrtc-jni's x86_64-macos-cross.cmake toolchain,
  so FFmpeg is configured as a cross build; Apple's strip reads any Mach-O,
  so its output stays stripped
- the CI actions build with an arm64 JDK and run only the tests on an x64
  one, which is what loading the Intel natives needs
@devopvoid
devopvoid added this pull request to stack #297 September 26, 2026 23:59
@devopvoid
devopvoid marked this pull request as ready for review September 27, 2026 09:45
@devopvoid
devopvoid merged commit dbc1bcc into main Sep 27, 2026
21 checks passed
@devopvoid
devopvoid deleted the build/macos-x86_64-native-cross branch September 27, 2026 09:46
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