1 |
13 |
serginhofr |
RISC-V GNU Compiler Toolchain
|
2 |
|
|
=============================
|
3 |
|
|
|
4 |
|
|
This is the RISC-V C and C++ cross-compiler. It supports two build modes:
|
5 |
|
|
a generic ELF/Newlib toolchain and a more sophisticated Linux-ELF/glibc
|
6 |
|
|
toolchain.
|
7 |
|
|
|
8 |
|
|
### Prerequisites
|
9 |
|
|
|
10 |
|
|
Several standard packages are needed to build the toolchain. On Ubuntu,
|
11 |
|
|
executing the following command should suffice:
|
12 |
|
|
|
13 |
|
|
$ sudo apt-get install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils
|
14 |
|
|
|
15 |
|
|
On Fedora/CentOS/RHEL OS, executing the following command should suffice:
|
16 |
|
|
|
17 |
|
|
$ sudo yum install autoconf automake autotools-devel libmpc-devel mpfr-devel gmp-devel gawk bison flex texinfo patchutils gcc
|
18 |
|
|
|
19 |
|
|
On Mac OS, the source and build directories must live in a case-sensitive file
|
20 |
|
|
system. The simplest approach is to create and mount a new disk image with
|
21 |
|
|
that property. Make sure that the mount point does not contain spaces.
|
22 |
|
|
|
23 |
|
|
This process will start by downloading about 200 MiB of upstream sources, then
|
24 |
|
|
will patch, build, and install the toolchain. If a local cache of the
|
25 |
|
|
upstream sources exists in $(DISTDIR), it will be used; the default location
|
26 |
|
|
is /var/cache/distfiles. Your computer will need about 8 GiB of disk space to
|
27 |
|
|
complete the process.
|
28 |
|
|
|
29 |
|
|
### Installation (Newlib)
|
30 |
|
|
|
31 |
|
|
To build the Newlib cross-compiler, pick an install path. If you choose,
|
32 |
|
|
say, `/opt/riscv`, then add `/opt/riscv/bin` to your `PATH` now. Then, simply
|
33 |
|
|
run the following command:
|
34 |
|
|
|
35 |
|
|
./configure --prefix=/opt/riscv
|
36 |
|
|
make
|
37 |
|
|
|
38 |
|
|
You should now be able to use riscv-gcc and its cousins.
|
39 |
|
|
|
40 |
|
|
### Installation (Linux)
|
41 |
|
|
|
42 |
|
|
To build the Linux cross-compiler, pick an install path. If you choose,
|
43 |
|
|
say, `/opt/riscv`, then add `/opt/riscv/bin` to your `PATH` now. Then, simply
|
44 |
|
|
run the following command:
|
45 |
|
|
|
46 |
|
|
./configure --prefix=/opt/riscv
|
47 |
|
|
make linux
|
48 |
|
|
|
49 |
|
|
### Installation (Linux multilib)
|
50 |
|
|
|
51 |
|
|
To build the Linux cross-compiler with support for both 32-bit and
|
52 |
|
|
64-bit, run the following commands:
|
53 |
|
|
|
54 |
|
|
./configure --prefix=/opt/riscv --enable-multilib
|
55 |
|
|
make linux
|
56 |
|
|
|
57 |
|
|
The multilib compiler will have the prefix riscv-unknown-linux-gnu-,
|
58 |
|
|
rather than the usual prefix (riscv32-... or riscv64-...).
|
59 |
|
|
|
60 |
|
|
### Advanced Options
|
61 |
|
|
|
62 |
|
|
There are a number of additional options that may be passed to
|
63 |
|
|
configure. See './configure --help' for more details.
|