Skip to content

Instantly share code, notes, and snippets.

@matty0005
Last active January 29, 2023 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matty0005/1d36d0d3634d686fd857748405d97806 to your computer and use it in GitHub Desktop.
Save matty0005/1d36d0d3634d686fd857748405d97806 to your computer and use it in GitHub Desktop.
Instructions to install the 32bit risc-v toolchain on apple silicon devices (eg, m1)

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment