Skip to content
Lu Yahan edited this page Mar 26, 2021 · 12 revisions

Getting Started

To build Node.js for RISC-V, start off by cloning this repository, then follow the steps below.

Prerequisites

Ensure that you have the RISC-V toolchain installed. If you do not have riscv64-unknown-linux-gnu-gcc available in your path, install it following the directions here.
If you have riscv64-unknown-linux-gnu-*, you can directly see here.

RISC-V Toolchain

Install Prerequisites
sudo apt install gawk texinfo zlib1g-dev flex bison
Build risc64-gnu Toolchain
git clone https://github.com/riscv/riscv-gnu-toolchain
cd riscv-gnu-toolchain
git submodule update --init --recursive

./configure --prefix=/opt/riscv
sudo make linux -j8

Note -j8 specifies parallel build with 8 processes, and should be adjusted to the number of cores on your machines.

Be sure to add the path to this new toolchain to your path:

export PATH="/opt/riscv/bin:$PATH"

Building Node.js

cd node
git submodule update --init --recursive

make binary \
    DESTCPU=riscv64 \
    CC=riscv64-unknown-linux-gnu-gcc \
    CXX=riscv64-unknown-linux-gnu-g++ \
    CC_host=gcc \
    CXX_host=g++ \
    CONFIG_FLAGS="--openssl-no-asm --build-v8-with-gn --cross-compiling" \
    -j$(nproc)

The above command both builds node and the related binaries in the out/Release directory and builds the release tarballs (e.g. node-v14.8.0-linux-riscv64.tar.gz and node-v14.8.0-linux-riscv64.tar.xz).

Clone this wiki locally