Skip to content

Commit

Permalink
Add support for building loong64
Browse files Browse the repository at this point in the history
  • Loading branch information
shipujin committed Jul 17, 2023
1 parent 4d945c0 commit 15034c1
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This list of officially supported platforms is available in the Node.js [BUILDIN
* **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".
* **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".
* **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)
* **loong64**: Linux loong64 (LoongArch64), cross compiled on Ubuntu 20.04 with the toolchain.

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

## Emeritus
Expand Down
1 change: 1 addition & 0 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ recipes=" \
x64-pointer-compression \
x64-usdt \
riscv64 \
loong64 \
"
ccachedir=$(realpath "${workdir}/.ccache")
stagingdir=$(realpath "${workdir}/staging")
Expand Down
34 changes: 34 additions & 0 deletions recipes/loong64/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM ubuntu:20.04

ARG GID=1000
ARG UID=1000

RUN addgroup --gid $GID node \
&& adduser --gid $GID --uid $UID --disabled-password --gecos node node

RUN apt-get update \
&& apt-get dist-upgrade -y \
&& apt-get install -y software-properties-common \
&& add-apt-repository -y ppa:ubuntu-toolchain-r/test \
&& apt-get update \
&& apt-get install -y \
git \
g++-13 \
curl \
make \
python3 \
python3-distutils \
ccache \
xz-utils

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

COPY --chown=node:node run.sh /home/node/run.sh

VOLUME /home/node/.ccache
VOLUME /out
VOLUME /home/node/node.tar.xz

USER node

ENTRYPOINT [ "/home/node/run.sh" ]
36 changes: 36 additions & 0 deletions recipes/loong64/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -e
set -x

release_urlbase="$1"
disttype="$2"
customtag="$3"
datestring="$4"
commit="$5"
fullversion="$6"
source_url="$7"
config_flags="--openssl-no-asm"

cd /home/node

tar -xf node.tar.xz
cd "node-${fullversion}"

export CC_host="ccache gcc-13"
export CXX_host="ccache g++-13"
export CC="ccache /opt/cross-tools/bin/loongarch64-unknown-linux-gnu-gcc"
export CXX="ccache /opt/cross-tools/bin/loongarch64-unknown-linux-gnu-g++"

make -j$(getconf _NPROCESSORS_ONLN) binary V= \
DESTCPU="loong64" \
ARCH="loong64" \
VARIATION="" \
DISTTYPE="$disttype" \
CUSTOMTAG="$customtag" \
DATESTRING="$datestring" \
COMMIT="$commit" \
RELEASE_URLBASE="$release_urlbase" \
CONFIG_FLAGS="$config_flags"

mv node-*.tar.?z /out/
10 changes: 10 additions & 0 deletions recipes/loong64/should-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash -xe

__dirname=$1
fullversion=$2

. ${__dirname}/_decode_version.sh

decode "$fullversion"

test "$major" -ge "20"

0 comments on commit 15034c1

Please sign in to comment.