Setting up RISC-V Toolchain on Ubuntu 24.04/22.04
Install dependencies
sudo apt install build-essential gawk texinfo bison flex libmpc-dev libz-dev
Create target directory
mkdir /scratch/tk/Documents/RISCV/
Clone riscv-gnu-toolchain repository
cd /scratch/tk/Downloads/
git clone https://github.com/riscv-collab/riscv-gnu-toolchain.git
cd ./riscv-gnu-toolchain/
To enable fp16 support, we need GCC 14.1.0. By 2024-12-29, the source has already bumped to GCC 14.2, so we don't need to do anything here.
The gcc submodule is from https://gcc.gnu.org/git/gcc.git, but here is a Github mirror of it that is more convenient to work with and reference:
Configure the project
./configure --prefix=/scratch/tk/Documents/RISCV/riscv64-unknown-toolchain/ --with-cmodel=medany --enable-multilib
prefix should match the target installation directory, and must be in absolute path.
Finally, build the project
make -j16
The toolchain should be installed in the target directory. Add the following to ~/.bashrc to include them on PATH
export RISCV="/scratch/tk/Documents/RISCV/"
export PATH="$RISCV/riscv64-unknown-toolchain/bin/:$PATH"
Last updated
Was this helpful?