app-builder icon indicating copy to clipboard operation
app-builder copied to clipboard

Unable to build arm64 native modules on Mac

Open mmaietta opened this issue 4 years ago • 0 comments

This is an issue that impacts electron-builder for arm64 Apple Silicon macs. Tested on v22.10.5

Using app-builder to generate .node files does not assemble them for the correct process architecture. Example:

➜  shell git:(master) yarn postinstall                                      
yarn run v1.22.10
$ npm run install:native

> [email protected] install:native /Development/shell
> electron-builder node-gyp-rebuild; electron-builder install-app-deps

  • loaded configuration  file=/Development/shell/electron-builder.js
  • executing node-gyp rebuild  platform=darwin arch=arm64
  • electron-builder  version=22.10.5
  • loaded configuration  file=/Development/shell/electron-builder.js
  • rebuilding native dependencies  [email protected] platform=darwin arch=arm64
  • rebuilding native dependency  name=electron-deeplink version=1.0.6
✨  Done in 11.66s.

➜  shell git:(master) find . -name "*.node"  -print0 | xargs -0 -n 1 lipo -i
Non-fat file: ./node_modules/electron-deeplink/build/Release/electron-deeplink.node is architecture: x86_64
Non-fat file: ./build/Release/uta_native.node is architecture: x86_64
Non-fat file: ./build/Release/app.node is architecture: x86_64

All node modules are built as x64 despite being on an arm64 device. The console log says executing node-gyp rebuild platform=darwin arch=arm64 but the output is not arm64.

If one attempts to force the arch, it still fails to produce the correct asset:

➜  shell git:(master) yarn electron-builder install-app-deps  --arch arm64                              
yarn run v1.22.10
$ /Development/shell/node_modules/.bin/electron-builder install-app-deps --arch arm64
  • electron-builder  version=22.10.5
  • loaded configuration  file=/Development/shell/electron-builder.js
  • rebuilding native dependencies  [email protected] platform=darwin arch=arm64
  • rebuilding native dependency  name=electron-deeplink version=1.0.6
✨  Done in 3.69s.
➜  shell git:(master) find . -name "*.node"  -print0 | xargs -0 -n 1 lipo -i
Non-fat file: ./node_modules/electron-deeplink/build/Release/electron-deeplink.node is architecture: x86_64

In comparison, if using electron-rebuild, all modules are properly generated for arm64 by default

➜  shell git:(master) yarn electron-rebuild --arch arm64 -f
....verbose output
➜  shell git:(master) ✗ find . -name "*.node"  -print0 | xargs -0 -n 1 lipo -i
Non-fat file: ./bin/darwin-arm64-85/shell.node is architecture: arm64
Non-fat file: ./node_modules/electron-deeplink/bin/darwin-arm64-85/electron-deeplink.node is architecture: arm64
Non-fat file: ./node_modules/electron-deeplink/build/Release/electron-deeplink.node is architecture: arm64
Non-fat file: ./build/Release/uta_native.node is architecture: arm64
Non-fat file: ./build/Release/app.node is architecture: arm64

mmaietta avatar Apr 15 '21 02:04 mmaietta