Note to self: When compiling the riscv-toolchain for embedded systems, set the configure options!
The toolchain can be cloned from the RISC-V official github. Once the dependencies are installed it’s straight forward to compile.
GCC itself can generate code for any RISC-V variant, however the support libraries must be compiled for a known target.
You have a choice to compile for just one architecture, or build the multilib support for a predefined set of architectures. I’m interested in 32 bit embedded, so have compiled for targets such as rv32imac or rv32ec.
The options for --march
and --mabi
are in the GCC documentation. Those need to be passed to the configure script to get the correct library.
Or with multilib (longer build).
Currently looking at configure.ac these are supported for multilib:
- rv32i-ilp32 (N)
- rv32iac-ilp32 (N)
- rv32im-ilp32 (N)
- rv32imac-ilp32 (A)
- rv32imafdc-ilp32d (G)
- rv32imafc-ilp32f (N)
- rv64imac-lp64 (A)
- rv64imafdc-lp64d (A)
(Where: (A)=all libs, (G)=glibc, (N)=newlib.)
After configure make
will build and INSTALL, hence the --prefix
directory should be writable to your user.