If you're having trouble compiling and installing the 32bit toolchain (riscv32-unknown-elf-gcc
, etc) for RISC-V on your
M1/Apple Silicon Mac, here is a guide to how I installed it.
brew edit riscv-gnu-toolchain
This will open a text editor of your choice. Inside this, you want to edit the args
on line 59 to
include the --with-arch=rv32i
and --with-abi=ilp32
arguments. The end result should look like:
args = [
"--prefix=#{prefix}",
"--with-cmodel=medany",
"--with-arch=rv32i",
"--with-abi=ilp32"
]
Once this is done, run
brew install riscv-tools
This will use the riscv-gnu-toolchain
that we just modified and will only install the
32bit toolchain (for embedded development)