Setting up the GNU GCC RISC-V Toolchain
I use Ubuntu on my X13s laptop, so, the logical choice developing RISC-V C programs on the move. Below is the instructions of how I set this up.
As always with Ubuntu we should do an update: sudo apt update followed by sudo apt upgrade
Next we install some prerequisites:
sudo apt install autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev
I am assuming you are creating this in your home directory, so, next mkdir RISCV to create a home for the toolchain and cd RISCV
We then clone the toolchain repository and build the gnu toolchain:
git clone --recursive https://github.com/riscv/riscv-gnu-toolchain
cd riscv-gnu-toolchain
mkdir build
cd build
../configure --prefix=/opt/riscv --with-arch=rv64gcv --with-abi=lp64d
sudo make -j$(nproc)
The toolchain should now be built and installed and we can test it.
export PATH=/opt/riscv/bin:$PATH
riscv64-unknown-elf-gcc -march=rv64gcv071 -o example example.c
Mission Accomplished
And there we have it, you can now build RISC-V binaries on an ARM Ubuntu laptop.