Skip to content

Commit b5bc78e

Browse files
authored
Merge pull request #189 from mollux/arm64-musl-support
add recipe to compile an arm64-musl version
2 parents 8fb00ef + 019b29d commit b5bc78e

File tree

4 files changed

+95
-0
lines changed

4 files changed

+95
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ This list of officially supported platforms is available in the Node.js [BUILDIN
3434
* **linux-armv6l**: Linux ARMv6 binaries, cross-compiled on Ubuntu 22.04 with a [custom GCC 12 toolchain](https://github.com/rvagg/rpi-newer-crosstools) (for Node.js 16 and later) in a similar manner to the official linux-armv7l binaries. Binaries are optimized for `armv6zk` which is suitable for Raspberry Pi devices (1, 1+ and Zero in particular). ARMv6 binaries were dropped from Node.js 12 and ARMv6 support is now considered "Experimental".
3535
* **riscv64**: Linux riscv64 (RISC-V), cross compiled on Ubuntu 20.04 with the toolchain which the Adoptium project uses (for now...). Built with --openssl-no-asm (Should be with --with-intl=none but that gets overriden)
3636
* **loong64**: Linux loong64 (LoongArch64), cross compiled on Ubuntu 20.04 with the toolchain.
37+
* **linux-arm64-musl**: Linux arm64 binaries compiled against [musl libc](https://www.musl-libc.org/). Primarily useful for users of Alpine Linux on arm64 hardware (e.g. Apple M1 machines). Linux arm64 with musl is considered "Experimental" by Node.js but the Node.js test infrastructure includes some Alpine test servers so support is generally good.
3738

3839
"Experimental" status for Node.js is defined as:
3940
> Experimental: May not compile or test suite may not pass. The core team does not create releases for these platforms. Test failures on experimental platforms do not block releases. Contributions to improve support for these platforms are welcome.

bin/_config.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ recipes=(
1010
"riscv64"
1111
"loong64"
1212
"x64-debug"
13+
"arm64-musl"
1314
)
1415

1516

recipes/arm64-musl/Dockerfile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
FROM alpine:3.22
2+
3+
ARG GID=1000
4+
ARG UID=1000
5+
6+
RUN addgroup -g $GID node \
7+
&& adduser -u $UID -G node -s /bin/sh -D node
8+
9+
RUN apk add --no-cache \
10+
libstdc++ \
11+
&& apk add --no-cache --virtual .build-deps \
12+
bash \
13+
binutils-gold \
14+
curl \
15+
g++ \
16+
gcc \
17+
gnupg \
18+
libgcc \
19+
linux-headers \
20+
make \
21+
python3 \
22+
ccache \
23+
xz \
24+
patch \
25+
# extra packages required for creating the musl based cross-compiler
26+
rsync make gcc g++ bzip2 git
27+
28+
COPY <<-EOF /config/config.mak
29+
# We only set the variables that are really needed, others are the sane defaults from the repo itself
30+
TARGET = aarch64-linux-musl
31+
GCC_VER = 14.2.0
32+
OUTPUT = /opt/aarch64-linux-musl-cross
33+
EOF
34+
35+
# set the version we want do use.
36+
# This is currently set to the last known working commit sha, as the lastest tag (v0.9.11) is not working
37+
# We specifically don't use the master branch as protection against rougue changes.
38+
# see following link for more context of what archives are available.
39+
# https://docs.github.com/en/repositories/working-with-files/using-files/downloading-source-code-archives#source-code-archive-urls
40+
RUN RELEASE="3635262e4524c991552789af6f36211a335a77b3" && \
41+
wget https://github.com/richfelker/musl-cross-make/archive/${RELEASE}.tar.gz && \
42+
tar -xzf ${RELEASE}.tar.gz && \
43+
cd /musl-cross-make-${RELEASE} && \
44+
make -I /config -j$(getconf _NPROCESSORS_ONLN) && \
45+
make -I /config install && \
46+
cd / && \
47+
rm -rf /musl-cross-make-${RELEASE}/ ${RELEASE}.tar.gz
48+
49+
COPY --chown=node:node run.sh /home/node/run.sh
50+
51+
VOLUME /home/node/.ccache
52+
VOLUME /out
53+
VOLUME /home/node/node.tar.xz
54+
55+
USER node
56+
57+
ENTRYPOINT [ "/home/node/run.sh" ]

recipes/arm64-musl/run.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
set -x
4+
5+
release_urlbase="$1"
6+
disttype="$2"
7+
customtag="$3"
8+
datestring="$4"
9+
commit="$5"
10+
fullversion="$6"
11+
source_url="$7"
12+
source_urlbase="$8"
13+
config_flags=""
14+
15+
cd /home/node
16+
17+
tar -xf node.tar.xz
18+
cd "node-${fullversion}"
19+
20+
export CC_host="ccache gcc"
21+
export CXX_host="ccache g++"
22+
export CC="ccache /opt/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc"
23+
export CXX="ccache /opt/aarch64-linux-musl-cross/bin/aarch64-linux-musl-g++ -static-libstdc++"
24+
25+
make -j$(getconf _NPROCESSORS_ONLN) binary V= \
26+
DESTCPU="arm64" \
27+
ARCH="arm64" \
28+
VARIATION="musl" \
29+
DISTTYPE="$disttype" \
30+
CUSTOMTAG="$customtag" \
31+
DATESTRING="$datestring" \
32+
COMMIT="$commit" \
33+
RELEASE_URLBASE="$release_urlbase" \
34+
CONFIG_FLAGS="$config_flags"
35+
36+
mv node-*.tar.?z /out/

0 commit comments

Comments
 (0)