blob: 654c405e4e9bcdcef603104ba3c71a6b3fa336ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
How to set up the cross-compilation toolchain
=============================================
RVController can run in little-endian or big-endian mode.
If you don't know what this means, you want little-endian.
These instructions are for Linux. Doing any of this on other OSes is left as an exercise for the reader.
Little-endian (recommended)
---------------------------
Target triplet is riscv32-none-elf. activate.sh will set this for you.
See c/rrxing/Makefile for example commands to compile and link.
Initial setup:
cd cross-toolchain
mkdir build target source
source activate.sh
Binutils (required):
cd source
git clone git://sourceware.org/git/binutils-gdb.git
cd ../build
mkdir binutils
cd binutils
../../source/binutils-gdb/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
make -j$(nproc)
make install # Do not use sudo! root access is not needed.
cd ../..
GCC (optional, needed if you want to use C but not Clang):
cd source
git clone https://gcc.gnu.org/git/gcc.git
cd ../build
mkdir gcc
cd gcc
../../source/gcc/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++ --without-headers --disable-hosted-libstdcxx --with-arch=RV32I
make -j$(nproc) all-gcc all-target-libgcc all-target-libstdc++-v3
make install-gcc install-target-libgcc install-target-libstdc++-v3 # Do not use sudo! root access is not needed.
cd ../..
Clang (recommended, needed if you want to use C but not GCC):
You can just use a copy of clang built for some other arch with "-target riscv32-none-elf".
If your distro ships a clang package, just install that.
Big-endian
----------
Target triplet is riscv32be-none-elf. activate-be.sh will set this for you.
See c/rrxing-be/Makefile for example commands to compile and link.
Initial setup:
cd cross-toolchain
mkdir build target source
source activate-be.sh
Binutils (required):
cd source
git clone git://sourceware.org/git/binutils-gdb.git
cd ../build
mkdir binutils-be
cd binutils-be
../../source/binutils-gdb/configure --target=$TARGET --prefix="$PREFIX" --with-sysroot --disable-nls --disable-werror
make -j$(nproc)
make install # Do not use sudo! root access is not needed.
cd ../..
Clang (recommended, required if you want to use C):
You can just use a copy of clang built for some other arch with "-target riscv32be-none-elf".
If your distro ships a clang package, just install that.
|