GNU toolchain for RISC-V, including GCC
Go to file
Palmer Dabbelt d66c792dfe Bump binutils
248124ac2e RISC-V: Add missing privileged spec registers.
bee792f83a RISC-V: Add compressed instruction hints, and a few misc cleanups.
7d895b6f4c Add missing RISC-V fsrmi and fsflagsi instructions.
04d33e4a83 Objcopy interleave fails if section address not multiple of interleave.
71a8fbb5aa Really fix riscv shared library __global_pointer$ problem.
355497b4a7 Riscv shared libraries should not export __global_pointer$.
bfd4dc4363 Fix for texinfo 4.8.
caf839a4a4 Update and clean up RISC-V gas documentation.
df726395c9 Give Palmer co-credit for last patch.
0362ab46db Fix riscv malloc error on small alignment after norvc.
3adcc16f76 Merge pull request #126 from riscv/native-gdb
be4ba40749 Make native gdb builds work.
2017-12-31 13:25:00 -08:00
linux-headers/include Move to glibc-2.26, and the latest Linux headers (riscv-for-submission-v7) 2017-08-21 17:03:59 -07:00
regression Add many "build-*" targets 2017-11-03 18:42:44 -07:00
riscv-binutils-gdb@248124ac2e Bump binutils 2017-12-31 13:25:00 -08:00
riscv-dejagnu@2e99dc08d8 Bump dejagnu, so the tests can run again 2017-12-15 11:58:26 -08:00
riscv-gcc@b731149757 Bump GCC 2017-11-07 14:59:50 -08:00
riscv-glibc@2f626de717 Move to glibc-2.26, and the latest Linux headers (riscv-for-submission-v7) 2017-08-21 17:03:59 -07:00
riscv-newlib@0bb64b9508 Bump newlib, to pick up nano.specs 2017-12-14 15:06:15 -08:00
riscv-qemu@ff36f2f77e Automate building QEMU 2017-08-20 13:49:57 -07:00
scripts Fail mail_tail when make fails 2017-09-22 17:09:38 -07:00
test Whitelist a log1p failure in newlib 2017-12-16 10:19:15 -08:00
.gitignore Add a local regression Makefile 2017-10-25 15:54:56 -07:00
.gitmodules Automate building QEMU 2017-08-20 13:49:57 -07:00
.travis.yml Don't run the glibc tests for now 2017-10-10 17:44:29 -07:00
LICENSE Add license 2016-04-20 14:02:45 -07:00
Makefile.in Fix relsrcdir problem that breaks regression Makefile. 2017-12-22 18:21:52 -08:00
README.md README Cleanups 2017-11-16 10:53:07 -08:00
configure Split the glibc and newlib multilib names in the Makefile 2017-09-13 16:48:58 -07:00
configure.ac Split the glibc and newlib multilib names in the Makefile 2017-09-13 16:48:58 -07:00

README.md

RISC-V GNU Compiler Toolchain

Build Status

This is the RISC-V C and C++ cross-compiler. It supports two build modes: a generic ELF/Newlib toolchain and a more sophisticated Linux-ELF/glibc toolchain.

Getting the sources

This repository uses submodules. You need the --recursive option to fetch the submodules automatically

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

Alternatively :

$ git clone https://github.com/riscv/riscv-gnu-toolchain
$ cd riscv-gnu-toolchain
$ git submodule update --init --recursive

Prerequisites

Several standard packages are needed to build the toolchain. On Ubuntu, executing the following command should suffice:

$ sudo apt-get install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev

On Fedora/CentOS/RHEL OS, executing the following command should suffice:

$ sudo yum install autoconf automake libmpc-devel mpfr-devel gmp-devel gawk  bison flex texinfo patchutils gcc gcc-c++ zlib-devel

On OS X, you can use Homebrew to install the dependencies:

$ brew install gawk gnu-sed gmp mpfr libmpc isl zlib

To build the glibc (Linux) on OS X, you will need to build within a case-sensitive file system. The simplest approach is to create and mount a new disk image with a case sensitive format. Make sure that the mount point does not contain spaces. This is not necessary to build newlib or gcc itself on OS X.

This process will start by downloading about 200 MiB of upstream sources, then will patch, build, and install the toolchain. If a local cache of the upstream sources exists in $(DISTDIR), it will be used; the default location is /var/cache/distfiles. Your computer will need about 8 GiB of disk space to complete the process.

Installation (Newlib)

To build the Newlib cross-compiler, pick an install path. If you choose, say, /opt/riscv, then add /opt/riscv/bin to your PATH now. Then, simply run the following command:

./configure --prefix=/opt/riscv
make

You should now be able to use riscv64-unknown-elf-gcc and its cousins.

Installation (Linux)

To build the Linux cross-compiler, pick an install path. If you choose, say, /opt/riscv, then add /opt/riscv/bin to your PATH now. Then, simply run the following command:

./configure --prefix=/opt/riscv
make linux

The build defaults to targetting RV64GC (64-bit), even on a 32-bit build environment. To build the 32-bit RV32GC toolchain, use:

./configure --prefix=/opt/riscv --with-arch=rv32gc --with-abi=ilp32d
make linux

Supported architectures are rv32i or rv64i plus standard extensions (a)tomics, (m)ultiplication and division, (f)loat, (d)ouble, or (g)eneral for MAFD.

Supported ABIs are ilp32 (32-bit soft-float), ilp32d (32-bit hard-float), ilp32f (32-bit with single-precision in registers and double in memory, niche use only), lp64 lp64f lp64d (same but with 64-bit long and pointers).

Installation (Linux multilib)

To build the Linux cross-compiler with support for both 32-bit and 64-bit, run the following commands:

./configure --prefix=/opt/riscv --enable-multilib
make linux

The multilib compiler will have the prefix riscv64-unknown-linux-gnu-, but will be able to target both 32-bit and 64-bit systems.

Advanced Options

There are a number of additional options that may be passed to configure. See './configure --help' for more details.

Test Suite

The DejaGnu test suite has been ported to RISC-V. This can run with GDB simulator for elf toolchain or Qemu for linux toolchain, and GDB simulator doesn't support floating-point. To test GCC, run the following commands:

./configure --prefix=$RISCV --disable-linux --with-arch=rv64ima # or --with-arch=rv32ima
make newlib
make report-newlib

./configure --prefix=$RISCV
make linux
make report-linux