How to build for Apple Silicon on GitHub Actions #1206
-
I am working on a Node package which has Apple Silicon as one of its target architectures. The auto-generated NAPI-RS GitHub Actions workflow makes sense to me when building for x64, but not for other architectures... This is how it builds for Intel Macs: - host: macos-latest
target: x86_64-apple-darwin
architecture: x64
build: |
yarn build
strip -x *.node While this is how it builds for Apple Silicon: - host: macos-latest
target: aarch64-apple-darwin
build: |
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*;
export CC=$(xcrun -f clang);
export CXX=$(xcrun -f clang++);
SYSROOT=$(xcrun --sdk macosx --show-sdk-path);
export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT";
yarn build --target aarch64-apple-darwin
strip -x *.node Given that GitHub Actions only has Intel Mac runners at the moment, I don't see anything in the build instructions that would produce an Apple Silicon binary. It's compiling the Could someone enlighten me as to how this works? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Intel macOS could compile Arm64 macOS binaries, the opposite is not possible. So while you are running |
Beta Was this translation helpful? Give feedback.
Intel macOS could compile Arm64 macOS binaries, the opposite is not possible. So while you are running
cargo build --target aarch64-apple-darwin
on Intel macOS, it will produce arm64 binary, not x86_64.