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 https://github.com/riscv/riscv-gnu-toolchain.git
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.
Links:
GCC arch/ABI reference: https://gcc.gnu.org/onlinedocs/gcc/RISC-V-Options.html
Sometimes it is handy to look at others’ compilation outputs: https://travis-ci.org/github/riscv/riscv-gnu-toolchain/
07. December 2020 by resset
Categories: Software |
Tags: embedded, GCC, risc-v, riscv, toolchain |
Leave a comment