How to build RISC-V GCC/newlib-nano toolchain

This short article will show you how to quickly setup cross-toolchain for C/C++ RV32IMAC binaries that runs on x86_64 host Linux PC.

git clone
cd riscv-gnu-toolchain/
git submodule update --init --recursive
mkdir build; cd build/
../configure --prefix=/opt/riscv32 --with-arch=rv32imac --with-abi=ilp32
make -j$(nproc)

Please note that /opt/riscv32 directory should be writable by the user running make. This command is the last step here, it will also install compilation results in –prefix directory. You might want to add bin directory to your PATH:

export PATH=/opt/riscv32/bin:$PATH

As a result we will get tools with riscv32-unknown-elf triplet.


GCC arch/ABI reference:

Sometimes it is handy to look at others’ compilation outputs:

07. December 2020 by resset
Categories: Software | Tags: , , , , | Leave a comment

Leave a Reply

Required fields are marked *