-
Notifications
You must be signed in to change notification settings - Fork 87
Add native Apple Silicon (ARM64) support for zap-cli builds #1607
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
base: master
Are you sure you want to change the base?
Conversation
- Add node18-macos-arm64 target to pkg configuration in package.json - Update pack-cli.js to properly handle ARM64 binary packaging - Remove outdated comments about ARM64 limitations - Enable native ARM64 compilation alongside existing x64 builds This resolves the issue where zap-mac-arm64.zip contained an Intel x86_64 binary requiring Rosetta translation on Apple Silicon Macs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @Chapoly1305, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request implements native Apple Silicon (ARM64) build support for the zap-cli macOS binary. Previously, the 'arm64' distribution contained an Intel x86_64 binary requiring Rosetta translation. With these changes, a true ARM64 binary is generated and packaged, providing native performance and a smaller size for users on Apple Silicon Macs.
Highlights
- Native ARM64 Build Target: Added the
node18-macos-arm64
target to thepkg
configuration inpackage.json
to enable the generation of a native Apple Silicon binary. - Updated Packaging Script: Modified
src-script/pack-cli.js
to correctly identify and package the newly generatedzap-macos-arm64
binary into thezap-mac-arm64.zip
distribution file, instead of packaging the x64 binary. - Removed Outdated Comments: Cleaned up comments in
src-script/pack-cli.js
that incorrectly statedpkg
did not support macOS ARM64 builds.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configureGemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds native Apple Silicon (ARM64) support for zap-cli
builds. The key change involves updating the pkg
configuration and the pack-cli.js
script. A critical adjustment is needed in src-script/pack-cli.js
to ensure the x64 binary is correctly renamed to zap-macos-x64
, aligning with the expected output of the pkg
tool when building for both architectures. Also, the pkg:mac
script in package.json
must be updated to build both architectures.
// Handle x64 build | ||
await rename(`${file}`, cli) | ||
await addToZip(`zap-mac-x64.zip`, cli) | ||
|
||
// NOTE: `pkg` build tool does not officially support building for mac arch64 yet. | ||
// until official support is out, x86 version will be packaged as | ||
// Apple Rosetta will kick in. | ||
// Handle arm64 build - pkg now supports macos-arm64 | ||
await rename(`${file}-arm64`, cli) | ||
await addToZip(`zap-mac-arm64.zip`, cli) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rename command for the x64 binary should use zap-macos-x64
to align with the expected output of the pkg
command when building for both x64 and arm64 architectures. This ensures the script correctly identifies and packages the x64 binary.
Also, ensure that the pkg:mac
script in package.json
builds both architectures to produce the expected filenames.
Style Guide References
// Handle x64 build | |
await rename(`${file}`, cli) | |
await addToZip(`zap-mac-x64.zip`, cli) | |
// NOTE: `pkg` build tool does not officially support building for mac arch64 yet. | |
// until official support is out, x86 version will be packaged as | |
// Apple Rosetta will kick in. | |
// Handle arm64 build - pkg now supports macos-arm64 | |
await rename(`${file}-arm64`, cli) | |
await addToZip(`zap-mac-arm64.zip`, cli) | |
// Handle x64 build | |
await rename(`zap-macos-x64`, cli) | |
await addToZip(`zap-mac-x64.zip`, cli) | |
// Handle arm64 build - pkg now supports macos-arm64 | |
await rename(`zap-macos-arm64`, cli) | |
await addToZip(`zap-mac-arm64.zip`, cli) |
Although it seems to work on Apple Silicon, it's still worth to mention the the original repo https://github.com/vercel/pkg states |
Apple Silicon (ARM64) Build Support for ZAP CLI
Problem
Original Issue: project-chip/connectedhomeip#39499
The original build device does not enable Rosetta 2 and resulted in build error.
Solution
Enable experimental support for Apple Silicon. We’ve updated the build configuration to support native ARM64 compilation using the modern
pkg
tool capabilities.Build Process
To generate both Intel and ARM64 binaries:
Results
Before Changes
zap-cli
: Intel x86_64 binary (97.7MB)After Changes
zap-macos-x64
: Intel x86_64 binary (93.8MB)zap-macos-arm64
: Native ARM64 binary (88.7MB)Verification