forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 4
Home
Lu Yahan edited this page Nov 6, 2023
·
12 revisions
To build Node.js for RISC-V, start off by cloning this repository, then follow the steps below.
Before cross build, 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.
sudo apt install gawk texinfo zlib1g-dev flex bison
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"
git clone [email protected]:nodejs/node.git
cd node/
git checkout v18.16.0
export CC=riscv64-unknown-linux-gnu-gcc
export CXX=riscv64-unknown-linux-gnu-g++
export CC_host=gcc
export CXX_host=g++
./configure --cross-compiling --dest-cpu=riscv64 --verbose --openssl-no-asm
make -j8
./configure --dest-cpu=riscv64 --verbose --openssl-no-asm
make
如果是交叉编译,需要讲 node相关文件拷贝到 riscv64机器上运行
打包nodejs文件
tar czvf riscv64.tar.gz --exclude=./out/Release/obj* --exclude=./out/Release/.deps ././out/Release ./test ./tools ./benchmark/ ./deps
将riscv64.tar.gz 拷贝到 riscv64机器
解压缩
tar xzvf riscv64.tar.gz
运行测试
./tools/test.py
./tools/test.py