Skip to content

build: ship a linux-arm64 prebuild - #217

Open
crazy159-ai wants to merge 2 commits into
cryptocoinjs:masterfrom
crazy159-ai:build/linux-arm64-prebuild
Open

crazy159-ai wants to merge 2 commits into
cryptocoinjs:masterfrom
crazy159-ai:build/linux-arm64-prebuild

Conversation

@crazy159-ai

@crazy159-ai crazy159-ai commented Nov 14, 2026 •

Copy link
Copy Markdown

Summary

prebuilds/ ships three platforms:

$ curl -sL https://registry.npmjs.org/secp256k1/-/secp256k1-5.0.2.tgz | tar -tz | grep '^package/prebuilds/'
package/prebuilds/linux-x64/secp256k1.glibc.node
package/prebuilds/linux-x64/secp256k1.musl.node
package/prebuilds/darwin-arm64/secp256k1.node
package/prebuilds/win32-x64/secp256k1.node

darwin-arm64 is there because macos-latest is an arm64 runner. linux-arm64
is not, because every Linux prebuild comes from prebuildify-cross, which only
targets the two images in the Makefile.

On an arm64 Linux host (Graviton, Ampere, arm64 build agents) node-gyp-build
finds no match and falls back to node-gyp rebuild. That works when a C++
toolchain is present, which is not the case for most deployment images — the
node:*-slim and node:*-alpine images ship no python3, make or g++.

The install script is

"install": "node-gyp-build || exit 0"

so a failed fallback build is swallowed. npm install reports success and the
first require('secp256k1') throws No native build was found for platform=linux arch=arm64. (utf-8-validate, same node-gyp-build setup, uses
the bare command and fails at install time instead.)

What this changes

Two lines, plus a one-line CI pin explained at the end:

 build-addon-linux:
-	$(prebuildify-cross) -i centos7-devtoolset7 -i alpine --target node@18.0.0 --napi --strip
+	$(prebuildify-cross) -i centos7-devtoolset7 -i alpine -i linux-arm64-lts --target node@18.0.0 --napi --strip
           mv darwin-arm64 prebuilds
           mv linux-x64 prebuilds
+          mv linux-arm64 prebuilds
           mv win32-x64 prebuilds

prebuildify-cross turns linux-arm64-lts into
ghcr.io/prebuild/linux-arm64-lts:2, and running the existing recipe on
ubuntu-latest now emits prebuilds/linux-arm64/secp256k1.armv8.node
alongside the x64 outputs. node-gyp-build resolves it because it parses the
armv8 tag against process.arch === 'arm64'.

Why linux-arm64-lts and not linux-arm64

The -lts image pins glibc 2.27, for the same reason the x64 build uses
centos7-devtoolset7 instead of a current distro. The plain linux-arm64 image
uses whatever glibc dockcross currently ships, so the binary would refuse to
load on older arm64 targets — exactly the class of problem documented in
websockets/bufferutil#150, which is why that project stopped shipping ARM
binaries altogether.

I did consider building natively on a GitHub arm64 runner instead. It avoids
cross-compilation, but ubuntu-24.04-arm is glibc 2.39 with GCC 13, so the
resulting prebuild would require a newer glibc than most arm64 targets have.
Cross-compiling against an old glibc is the smaller risk.

Known limitation

Alpine arm64 is unchanged: it still compiles from source. It cannot be added
here without more work, because prebuildify-cross tags linux-arm64* images
with --tag-armv only, so linux-arm64-lts and linux-arm64-musl would both
emit secp256k1.armv8.node and overwrite each other. Fixing that needs either a
--tag-libc-aware arm64 image upstream or a rename step after the build. Happy
to follow up separately; this PR is strictly better than the current zero arm64
prebuilds.

Test plan

  • The existing make test-tap step runs on every build job and loads the
    prebuild through bindings, so a broken arm64 binary fails CI.
  • After a release: npm install secp256k1 on an arm64 Linux host should show no
    gyp output.

Open question

Should the install script stay node-gyp-build || exit 0? With a prebuild in
place it matters less, but on a platform that still has no prebuild and no
toolchain, the package installs successfully and then throws at require time.
Removing || exit 0 turns that into an install-time error. Happy to put that in
a second commit if you want it.

Note on CI

ubuntu-latest now resolves to Ubuntu 26.04, whose Docker daemon rejects the
API version prebuildify-cross pins (v1.24), so make build-addon-linux
fails before it pulls an image. That is unrelated to the arm64 change — it
fails identically on unmodified master
(control run)
— but it stops this PR from being verified at all.

The second commit pins the Linux job to ubuntu-24.04 (Docker 28.0.4),
matching the existing windows-2022 pin. The evidence that the pinned API
version is the cause: asking the daemon for /v1.24/version returns 200 on
ubuntu-24.04 and non-200 on ubuntu-latest
(probe).

Drop that commit if you would rather handle CI separately. With it, the Linux
job builds the new prebuilds/linux-arm64 and the package job succeeds —
which it can only do if mv linux-arm64 prebuilds finds the directory.

🤖 Generated with Claude Code

crazy159-ai and others added 2 commits November 14, 2026 11:42
linux-arm64 was the only platform with an x64 prebuild but no arm64
counterpart. Without one, node-gyp-build falls back to compiling from
source on arm64 Linux, and because the install script is
`node-gyp-build || exit 0`, a failed fallback installs a package that
only throws when it is required.

Build it with the linux-arm64-lts image so the prebuild keeps a glibc
2.27 floor, for the same reason x64 uses centos7-devtoolset7.

Co-Authored-By: Claude Code <noreply@anthropic.com>
ubuntu-latest now resolves to Ubuntu 26.04, whose Docker daemon rejects
the API version prebuildify-cross pins (v1.24). `make build-addon-linux`
therefore fails before it pulls an image:

  /v1.24/version -> non-200 on ubuntu-latest, 200 on ubuntu-24.04

The same failure happens on unmodified master, so it is unrelated to the
arm64 change, but it stops this PR from being verified. Pinning matches
the existing windows-2022 pin.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant