electron-userland / electron-builder

A complete solution to package and build a ready for distribution Electron app with “auto update” support out of the box
https://www.electron.build
MIT License
13.71k stars 1.74k forks source link

ARM64 rebuild package not working - always deploys X86 #8677

Open supertick opened 1 week ago

supertick commented 1 week ago

Trying to cross compile on a github action runner for arm64 (raspi) for serialport bindings

  "package": "yarn prebuild && yarn build && yarn copy-public",
  "package-linux-arm64": "yarn package && npx electron-rebuild -f --arch=arm64 && electron-builder --linux AppImage --arm64",

The rebuild reports arm64

  COPY Release/cpufeatures.node
make: Leaving directory '/home/runner/work/robotlab-x/robotlab-x/server/node_modules/cpu-features/build'
✔ Rebuild Complete
  • electron-builder  version=25.1.8 os=6.5.0-1025-azure
  • loaded configuration  file=package.json ("build" field)
  • @electron/rebuild already used by electron-builder, please consider to remove excess dependency from devDependencies

To ensure your native dependencies are always matched electron version, simply add script `"postinstall": "electron-builder install-app-deps" to your `package.json`
  • executing @electron/rebuild  electronVersion=31.7.3 arch=arm64 buildFromSource=false appDir=./
  • installing native dependencies  arch=arm64
  • preparing       moduleName=@serialport/bindings arch=arm64
  • finished        moduleName=@serialport/bindings arch=arm64
  • preparing       moduleName=@serialport/bindings-cpp arch=arm64
  • finished        moduleName=@serialport/bindings-cpp arch=arm64
  • preparing       moduleName=cpu-features arch=arm64
  • finished        moduleName=cpu-features arch=arm64
  • completed installing native dependencies
  • packaging       platform=linux arch=arm64 electron=31.7.3 appOutDir=/home/runner/work/robotlab-x/robotlab-x/dist/packages/linux-arm64-unpacked
  • downloading     url=https://github.com/electron/electron/releases/download/v31.7.3/electron-v31.7.3-linux-arm64.zip size=106 MB parts=8
  • downloaded      url=https://github.com/electron/electron/releases/download/v31.7.3/electron-v31.7.3-linux-arm64.zip duration=432ms
  • building        target=AppImage arch=arm64 file=/home/runner/work/robotlab-x/robotlab-x/dist/packages/robotlab-x-0.9.224-arm64.AppImage
  • downloading     url=https://github.com/electron-userland/electron-builder-binaries/releases/download/appimage-12.0.1/appimage-12.0.1.7z size=1.6 MB parts=1
  • downloaded      url=https://github.com/electron-userland/electron-builder-binaries/releases/download/appimage-12.0.1/appimage-12.0.1.7z duration=141ms
Done in 25.02s.

The AppImage is arm64 but the serialport/bindings are x86:

file /tmp/.mount_robotlxD4414/resources/app.asar.unpacked/node_modules/@serialport/bindings/build/Release/bindings.node
/tmp/.mount_robotlxD4414/resources/app.asar.unpacked/node_modules/@serialport/bindings/build/Release/bindings.node: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=b386300dd94cd02c193230bd3b319aee2fe19472, not stripped
mmaietta commented 1 week ago

Can you try with v26.0.0-alpha.6?

I contributed some changes upstream to electron/rebuild and electron-builder updated that dependency in one of the recent alpha versions. Note: you shouldn't need npx electron-rebuild -f --arch=arm64 in your build script.

supertick commented 1 week ago

Thanks, I tried v26.0.0-alpha.6, both with npx electron-rebuild -f --arch=arm64 && and without. Always with electron-builder --linux AppImage --arm64 Same behavoir, it appears to correctly build the executable but, the AppImage release contains x86-64 binaries image

mmaietta commented 1 week ago

Can you share a minimum reproducible repo that I could take a look at? This sounds like a bug in @electron/rebuild that I could investigate and fix upstream.

To hopefully unblock you, you can use the previous app-builder-bin implementation, set nativeRebuilder: legacy in your config.

supertick commented 1 week ago

The project is currently green shield in github - https://github.com/RobotLab-X/robotlab-x This is the package.json defining the arm 64 build: https://github.com/RobotLab-X/robotlab-x/blob/main/server/package.json

Steps to reproduce should be straight forward: on a linux x86 64 machine:

git clone https://github.com/RobotLab-X/robotlab-x.git
cd robotlab-x
yarn install-all
yarn build-client
yarn install-client
yarn package-linux-arm64

An AppImage will get created in dist/packages. It will be executable on arm64 - but the file extracted in /tmp/.mount ..../resources/app.asar.unpacked/node_modules /Release/bindings.node will be a x86-64 binary

Thanks for looking into this :)

supertick commented 1 week ago

At the moment I have a self-hosted git runner that's building it on a raspi since the cross compiler deployment isn't working