Repository navigation
fix(ci): fail releases that bundle native code for the wrong CPU - #54982
Conversation
2.0.27's ARM64 Windows CLI embedded an x64 rust_pty.dll and its ARM64 desktop bundled x64 node-pty. Both only fail on ARM64 hardware, which CI never runs, so the build now checks every native image against the target.
There was a problem hiding this comment.
The check works as described, and I found nothing that should block a merge.
How I checked it: I cross-compiled small Bun executables that embed bun-pty's arm64 or x64 rust_pty library. Windows ARM64 and Darwin ARM64 builds pass with the matching library and fail with the wrong one (has PE x64 at byte …, Mach-O x64). A Linux x64 build that embeds an arm64 DLL also fails. I also ran script/build.ts with the check for opencode-windows-arm64 and opencode-darwin-x64. Both builds finished cleanly; the Windows ARM64 binary has 7 arm64 images and nothing else. Typecheck passes in packages/cli and packages/desktop, and the desktop config tests pass.
I didn't run the desktop afterPack checks because they need real electron-builder packaging. From reading the code, the arch comparison matches the publish.yml desktop matrix.
Public API: unchanged (build and packaging scripts only).
Related: #54689
2.0.27 shipped two Windows ARM64 regressions that every check passed. Each one shows up only on ARM64 hardware, which CI never runs:
rust_pty.dll(bun-pty 0.4.9), so no terminal could open.@lydell/node-pty-win32-x64, so WSL commands failed.Both are fixed on
dev(#54689). This PR fails the build if either class of bug comes back.script/native-arch.tsfinds every PE, ELF and Mach-O image in a file, including the libraries Bun and Node SEA embed in a compiled executable, and reads each image's CPU. A universal Mach-O counts as all of its slices.Against shipped binaries
cli-windows-arm64rust_pty.dll)dev's bun-pty 0.4.11 + OpenTUI + fffrust_pty.dllEach scan of a ~200 MB executable takes about 300 ms.
afterPack, driven with real binaries and node-pty prebuildsOPENCODE_CLI_TARGETleft on the x64 hostPackaging arm64 Electron with the x86_64-pc-windows-msvc CLIopencode-cli.exe must contain only arm64 code, but has PE x64 at byte 199953284conpty_console_list.node must contain only arm64 codeAdded by the opencode bot (AI-generated).
Related: #54689