Skip to main content

RISC-V GCC Toolchain Installation

· loading · loading · · ·
HDL Verilog HDL
Axolot Logic
Author
Axolot Logic
Digital Design Engineer
Table of Contents

✅ RISC-V GCC Toolchain Installation Guide (Ubuntu)
#

This guide explains two methods for installing the RISC-V GCC toolchain on Ubuntu:

  1. Prebuilt binaries for quick setup
  2. Building from source for full control and customization

🔹 Method 1: Installing Prebuilt RISC-V GCC Toolchain
#

This method is ideal for quick setup and testing.

🧩 Required Dependencies (applies to both methods)
#

sudo apt update
sudo apt install build-essential wget tar libgmp-dev libmpfr-dev libmpc-dev libisl-dev texinfo -y

📥 1.1 Downloading the Toolchain
#

You can get prebuilt toolchains from the NEORV32 project or community builds.

Status Version GCC Binutils Arch ABI Lib
🟢 rv32e-231223 13.2.0 2.41 rv32e ilp32e newlib
🟢 rv32i-131023 13.2.0 2.41 rv32i ilp32 newlib
🔴 rv32i-4.0.0 12.1.0 2.39 rv32i ilp32 newlib

📦 Example (Download via terminal)
#

wget https://github.com/stnolting/riscv-gcc-prebuilt/releases/download/rv32i-131023/riscv32-unknown-elf.gcc-13.2.0.tar.gz

🛠 1.2 Installing the Toolchain
#

Create install directory:
#

sudo mkdir -p /opt/riscv

Extract the archive:
#

sudo tar -xzf riscv32-unknown-elf.gcc-13.2.0.tar.gz -C /opt/riscv/

🧭 1.3 Setting the PATH
#

echo 'export PATH=$PATH:/opt/riscv/bin' >> ~/.bashrc
source ~/.bashrc

✅ 1.4 Verifying the Installation
#

riscv32-unknown-elf-gcc -v

You should see something like:

Using built-in specs.
COLLECT_GCC=riscv32-unknown-elf-gcc
Target: riscv32-unknown-elf
...

🔸 Method 2: Building the Toolchain from Source
#

This method gives you full control over architecture, ABI, C library, etc.

📦 2.1 Additional Dependencies
#

sudo apt install autoconf automake curl python3 gawk bison flex texinfo gperf libtool patchutils -y

📁 2.2 Cloning the Toolchain Repository
#

git clone --recursive https://github.com/riscv-collab/riscv-gnu-toolchain
cd riscv-gnu-toolchain

🔧 2.3 Configure the Build
#

Example for rv32imc + newlib:

./configure --prefix=/opt/riscv --with-arch=rv32imc --with-abi=ilp32 --with-newlib
  • --prefix = install path
  • --with-arch = architecture
  • --with-abi = ABI format
  • --with-newlib = use newlib C library (bare-metal)

🛠 2.4 Build the Toolchain
#

make newlib

For Linux-hosted toolchain (e.g., for Linux OS targets), use make linux instead.

⚠️ This step may take 30–60 minutes depending on your system.


🧭 2.5 Set PATH
#

echo 'export PATH=$PATH:/opt/riscv/bin' >> ~/.bashrc
source ~/.bashrc

✅ 2.6 Verify the Build
#

riscv32-unknown-elf-gcc -v

🧠 Tips & Comparison
#

Scenario Recommended Method
Quick installation / testing ✅ Prebuilt
Architecture customization ✅ Source build
Linux-targeted toolchain ✅ Source build with make linux

📚 Resources
#


Related

Blocking vs Non-Blocking Assignments
· loading · loading
HDL Verilog HDL
Command-Line Input
· loading · loading
HDL Verilog HDL
Compiler Directives & Macros
· loading · loading
HDL Verilog HDL
Control Flow
· loading · loading
HDL Verilog HDL
Delay Controls
· loading · loading
HDL Verilog HDL
Git Installition for Windows
· loading · loading
HDL Verilog HDL