fix: resolve native module architecture mismatch in Linux ARM64 builds#1055
Open
yunho0130 wants to merge 1 commit intopinokiocomputer:mainfrom
Open
fix: resolve native module architecture mismatch in Linux ARM64 builds#1055yunho0130 wants to merge 1 commit intopinokiocomputer:mainfrom
yunho0130 wants to merge 1 commit intopinokiocomputer:mainfrom
Conversation
When building Linux ARM64 packages from an x86-64 host (e.g. Docker), native .node modules (node-pty, @parcel/watcher, bufferutil) are compiled for x86-64 and incorrectly bundled into the ARM64 package. This happens because electron-builder's install-app-deps runs once for the host architecture, and @electron/rebuild skips prebuilt modules without verifying the target architecture. Add a fix-native-modules.js afterPack hook that: - Detects cross-compilation (host arch != target arch) - Scans all active .node files in app.asar.unpacked for arch mismatches - Replaces mismatched binaries from prebuilds/ directories (node-pty) - Downloads correct platform-specific npm packages (@parcel/watcher) - Cross-compiles N-API modules when toolchain is available (bufferutil) Tested on Ubuntu 24.04 ARM64 (aarch64) with Pinokio v6.0.10. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.nodemodules, which causes immediate crash on ARM64 systemsfix-native-modules.jsafterPack hook that detects cross-compilation and replaces mismatched binaries@homebridge/node-pty-prebuilt-multiarch,@parcel/watcher,bufferutilProblem
When building Linux ARM64
.deb/.rpm/.AppImagepackages from an x86-64 Docker host (electronuserland/builder), native.nodemodules are compiled for x86-64 and incorrectly bundled into the ARM64 package.Root cause:
electron-builder install-app-depsruns once for the host architecture (process.arch = x64), and@electron/rebuildskips prebuilt modules (viaprebuildInstallNativeModuleExists()) without verifying the target architecture matches.Runtime errors on ARM64:
Solution
Add a
fix-native-modules.jsafterPack hook (called fromafter-pack.js) that:.nodefiles inapp.asar.unpackedusing thefilecommand to check ELF architectureprebuilds/linux-<arch>/directory (e.g.node-pty)@parcel/watcher-linux-arm64-glibc)bufferutil)The hook is a no-op when host and target architectures match (no performance impact for native builds).
Test plan
.debships x86-64 native modulespty.node,watcher.node,bufferutil.node) with ARM64 versions🤖 Generated with Claude Code