explaingit

riscv-collab/riscv-gnu-toolchain

4,486CAudience · developerComplexity · 4/5Setup · hard

TLDR

A cross-compiler that translates C and C++ code into programs for RISC-V processors, supporting both bare-metal firmware and Linux applications.

Mindmap

mindmap
  root((riscv-gnu-toolchain))
    Toolchain types
      Bare-metal Newlib
      Linux glibc
      Linux musl
    Target options
      32-bit rv32
      64-bit rv64
      Multilib combined
    Configuration
      Architecture extensions
      ABI selection
      Extra languages
    Build requirements
      8 GB disk space
      Linux or macOS
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Build C firmware that runs directly on a RISC-V microcontroller with no operating system underneath.

USE CASE 2

Compile Linux applications in C or C++ that run on a RISC-V single-board computer or development board.

USE CASE 3

Set up a cross-compilation environment on a laptop to produce RISC-V binaries for custom hardware.

USE CASE 4

Build a multilib toolchain that supports both 32-bit and 64-bit RISC-V targets in one installation.

Tech stack

CGCCNewlibglibcmusl

Getting it running

Difficulty · hard Time to first run · 1h+

Requires 8 GB disk, 6.65 GB download, and platform-specific build dependencies, the build can take 30 or more minutes.

In plain English

This repository contains the GNU compiler toolchain for RISC-V, a type of processor architecture used in everything from microcontrollers to server chips. A compiler toolchain is the collection of programs that translate code you write in C or C++ into machine instructions that a specific processor can actually run. Since RISC-V processors typically run on a different machine than the one you use to write code, this is called a cross-compiler: you build it on your laptop or desktop and use it to produce programs that run on a RISC-V chip elsewhere. The toolchain comes in two main flavors. The first is a bare-metal version built around a small standard library called Newlib, intended for programs that run directly on hardware with no operating system underneath, such as firmware or embedded microcontroller code. The second is a Linux version built around the glibc or musl standard libraries, intended for programs that run on a Linux-based operating system on a RISC-V device. You choose which one to build by running a configure step and then either make or make linux. Building from source takes significant resources: cloning the repository requires about 6.65 GB of network download, the build process downloads an additional 200 MB of upstream sources, and the whole process needs around 8 GB of disk space. The README provides installation commands for Ubuntu, Fedora, Arch Linux, and macOS to install the required build dependencies before starting. The toolchain supports both 32-bit and 64-bit RISC-V targets, and you can build a combined multilib version that handles both in one installation. Configuration options let you choose the target architecture extensions (integer, multiply, float, atomic, and others), the ABI (how function arguments are passed), big-endian targets, and additional languages like Fortran. The README includes troubleshooting notes covering common problems on macOS (which requires a case-sensitive filesystem for the Linux glibc build), on older CentOS systems that ship outdated build tools, and on mixing soft-float and hard-float toolchain builds in the same install directory.

Copy-paste prompts

Prompt 1
Walk me through building riscv-gnu-toolchain for bare-metal RISC-V on Ubuntu, targeting rv32imac with the ilp32 ABI.
Prompt 2
I am getting a build error with riscv-gnu-toolchain on macOS. The README says I need a case-sensitive filesystem, how do I set that up?
Prompt 3
Configure riscv-gnu-toolchain to build a Linux glibc toolchain for a 64-bit RISC-V target and test it with a hello-world C program.
Prompt 4
How do I add Fortran language support when building riscv-gnu-toolchain from source?
Prompt 5
Build a multilib riscv-gnu-toolchain that handles both rv32 and rv64 targets from a single installation.
Open on GitHub → Explain another repo

← riscv-collab on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.