Skip to content

Commit 15034c1

Browse files
shipujinShi Pujin
authored andcommitted
Add support for building loong64
1 parent 4d945c0 commit 15034c1

File tree

5 files changed

+83
-0
lines changed

5 files changed

+83
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This list of officially supported platforms is available in the Node.js [BUILDIN
1717
* **linux-x86**: Linux x86 (32-bit) binaries compiled against libc 2.17, similar to the way the official [linux-x64 binaries are produced](https://github.com/nodejs/node/blob/master/BUILDING.md#official-binary-platforms-and-toolchains). 32-bit Linux binaries were dropped for Node.js 10 and 32-bit support is now considered "Experimental".
1818
* **linux-armv6l**: Linux ARMv6 binaries, cross-compiled on Ubuntu 16.04 with a [custom GCC 6 toolchain](https://github.com/rvagg/rpi-newer-crosstools) (for Node.js versions earlier than 16) or Ubuntu 18.04 with a [custom GCC 8 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".
1919
* **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)
20+
* **loong64**: Linux loong64 (LoongArch64), cross compiled on Ubuntu 20.04 with the toolchain.
2021

2122
"Experimental" status for Node.js is defined as:
2223
> 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.
@@ -67,6 +68,7 @@ unofficial-builds is maintained by:
6768
* [@rvagg](https://github.com/rvagg)
6869
* [@richardlau](https://github.com/richardlau)
6970
* [@sxa](https://github.com/sxa)
71+
* [@shipujin](https://github.com/shipujin)
7072
* ... _contribute something and add yourself here!_
7173

7274
## Emeritus

bin/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ recipes=" \
1818
x64-pointer-compression \
1919
x64-usdt \
2020
riscv64 \
21+
loong64 \
2122
"
2223
ccachedir=$(realpath "${workdir}/.ccache")
2324
stagingdir=$(realpath "${workdir}/staging")

recipes/loong64/Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM ubuntu:20.04
2+
3+
ARG GID=1000
4+
ARG UID=1000
5+
6+
RUN addgroup --gid $GID node \
7+
&& adduser --gid $GID --uid $UID --disabled-password --gecos node node
8+
9+
RUN apt-get update \
10+
&& apt-get dist-upgrade -y \
11+
&& apt-get install -y software-properties-common \
12+
&& add-apt-repository -y ppa:ubuntu-toolchain-r/test \
13+
&& apt-get update \
14+
&& apt-get install -y \
15+
git \
16+
g++-13 \
17+
curl \
18+
make \
19+
python3 \
20+
python3-distutils \
21+
ccache \
22+
xz-utils
23+
24+
RUN curl https://github.com/loongson/build-tools/releases/download/2022.09.06/loongarch64-clfs-7.3-cross-tools-gcc-glibc.tar.xz | tar xJf - -C /opt
25+
26+
COPY --chown=node:node run.sh /home/node/run.sh
27+
28+
VOLUME /home/node/.ccache
29+
VOLUME /out
30+
VOLUME /home/node/node.tar.xz
31+
32+
USER node
33+
34+
ENTRYPOINT [ "/home/node/run.sh" ]

recipes/loong64/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+
3+
set -e
4+
set -x
5+
6+
release_urlbase="$1"
7+
disttype="$2"
8+
customtag="$3"
9+
datestring="$4"
10+
commit="$5"
11+
fullversion="$6"
12+
source_url="$7"
13+
config_flags="--openssl-no-asm"
14+
15+
cd /home/node
16+
17+
tar -xf node.tar.xz
18+
cd "node-${fullversion}"
19+
20+
export CC_host="ccache gcc-13"
21+
export CXX_host="ccache g++-13"
22+
export CC="ccache /opt/cross-tools/bin/loongarch64-unknown-linux-gnu-gcc"
23+
export CXX="ccache /opt/cross-tools/bin/loongarch64-unknown-linux-gnu-g++"
24+
25+
make -j$(getconf _NPROCESSORS_ONLN) binary V= \
26+
DESTCPU="loong64" \
27+
ARCH="loong64" \
28+
VARIATION="" \
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/

recipes/loong64/should-build.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash -xe
2+
3+
__dirname=$1
4+
fullversion=$2
5+
6+
. ${__dirname}/_decode_version.sh
7+
8+
decode "$fullversion"
9+
10+
test "$major" -ge "20"

0 commit comments

Comments
 (0)