fix: add 32-bit Linux (ia32 + armv7l) prebuilds#7
Conversation
Old release lines (notably Electron's armv7l builds) still install @electron-internal/extract-zip, but no 32-bit prebuild was being shipped, so it failed to load on 32-bit Linux. Add cross-compiled prebuilds for both 32-bit Linux targets: - i686-unknown-linux-gnu (linux/ia32) via gcc-multilib - armv7-unknown-linux-gnueabihf (linux/arm) via napi's --use-napi-cross Both run in the shared CI build matrix (reused by the Release workflow via workflow_call) and are flagged `cross: true` so the smoke-test step is skipped — there are no native 32-bit runners and the host's 64-bit node can't load a 32-bit .node. napi's generated loader has no `process.arch === 'ia32'` branch under Linux, so strip-binding-fallbacks.js now also splices that branch in; otherwise the ia32 prebuild would be unreachable. package.json targets and the check-prebuilds publish gate are updated to match.
| // ── 2) Inject the linux/ia32 branch ─────────────────────────────────────── | ||
| const ia32Marker = "require('./index.linux-ia32-gnu.node')"; | ||
| if (src.includes(ia32Marker)) { | ||
| console.log('strip-binding-fallbacks: linux/ia32 branch already present'); | ||
| } else { | ||
| // Anchor on the Linux-specific "unsupported arch" else; insert before it. | ||
| const anchor = | ||
| ' } else {\n loadErrors.push(new Error(`Unsupported architecture on Linux:'; | ||
| if (!src.includes(anchor)) { | ||
| console.error('strip-binding-fallbacks: linux unsupported-arch anchor not found — generator output changed?'); | ||
| process.exit(1); | ||
| } | ||
| const ia32Branch = | ||
| " } else if (process.arch === 'ia32') {\n" + | ||
| ' try {\n' + | ||
| ` return ${ia32Marker}\n` + | ||
| ' } catch (e) {\n' + | ||
| ' loadErrors.push(e)\n' + | ||
| ' }\n'; | ||
| src = src.replace(anchor, ia32Branch + anchor); | ||
| console.log('strip-binding-fallbacks: added linux/ia32 branch to binding.js'); | ||
| } |
There was a problem hiding this comment.
I think this would be more maintainable as a patch to @napi-rs/cli, since Yarn v4 makes it easy enough to patch dependencies.
There was a problem hiding this comment.
Good call — done in 923fc8a. Patched @napi-rs/cli's loader template via Yarn's patch protocol so napi now emits the process.arch === 'ia32' Linux branch natively (consistent with every other arch, fallback and all), and reverted strip-binding-fallbacks.js back to its original single responsibility. The @electron-internal fallback that the patched branch generates is still stripped by the existing step.
Generated by Claude Code
Address review feedback: instead of splicing the missing 32-bit x86 Linux branch into the generated binding.js from strip-binding-fallbacks.js, patch @napi-rs/cli's loader template directly (via Yarn's patch protocol) so napi emits the `process.arch === 'ia32'` branch natively, consistent with every other arch (including its @electron-internal fallback, which the existing strip step then removes). strip-binding-fallbacks.js is reverted to its original single responsibility.
|
Can we add the following to the PR description?
|
|
Done! |
|
Changing this from |
|
🎉 This PR is included in version 1.0.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Old release lines (notably Electron's armv7l builds) still install @electron-internal/extract-zip, but no 32-bit prebuild was being shipped, so it failed to load on 32-bit Linux. Add cross-compiled prebuilds for both 32-bit Linux targets:
Both run in the shared CI build matrix (reused by the Release workflow via workflow_call) and are flagged
cross: trueso the smoke-test step is skipped — there are no native 32-bit runners and the host's 64-bit node can't load a 32-bit .node.napi's generated loader has no
process.arch === 'ia32'branch under Linux, so strip-binding-fallbacks.js now also splices that branch in; otherwise the ia32 prebuild would be unreachable. package.json targets and the check-prebuilds publish gate are updated to match.Fixes #6
Refs electron/electron#51963