-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmk_riscv_toolchain.sh
executable file
·140 lines (108 loc) · 2.95 KB
/
mk_riscv_toolchain.sh
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
set -x
THIS=$(pwd)
host_root=$(pwd)/host_root
target_root=$host_root/riscv64_target_root
wget https://mirrors.tuna.tsinghua.edu.cn/kernel/v5.x/linux-5.18.17.tar.gz
tar -xf linux-5.18.17.tar.gz &
wget https://mirrors.tuna.tsinghua.edu.cn/gnu/binutils/binutils-2.39.tar.gz
tar -xf binutils-2.39.tar.gz &
wget https://mirrors.tuna.tsinghua.edu.cn/gnu/glibc/glibc-2.35.tar.gz
tar -xf glibc-2.35.tar.gz &
wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-11.3.0/gcc-11.3.0.tar.gz
tar -xf gcc-11.3.0.tar.gz &
wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gdb/gdb-12.1.tar.gz
tar -xf gdb-12.1.tar.gz &
wait
sudo apt install gcc g++ make texinfo
sudo apt install libgmp-dev libmpfr-dev libmpc-dev # for building gcc
sudo apt install gawk bison flex # for building glibc
sudo apt install libelf-dev libssl-dev # for building kernel
sudo apt install libncurses-dev
sudo apt install pkg-config
sudo apt install libdebuginfod-dev libexpat1-dev # for building gdb
sudo apt install libpython2-dev libpython3-dev libpython-all-dev python2 python3 python-is-python3 # for building gdb
sudo apt install guile-3.0-dev # for building gdb
rm -rf ${host_root}
mkdir gdb_build
cd gdb_build
rm -rf *
../gdb-12.1/configure \
--prefix=${host_root}/usr \
--target=riscv64-linux-gnu \
--disable-sim \
--with-curses \
--with-debuginfod \
--with-expat \
--with-mpfr \
--with-python \
--with-guile
make -j12
make install -j12
cd ..
mkdir binutils_build
cd binutils_build
rm -rf *
../binutils-2.39/configure \
--prefix=${host_root}/usr \
--target=riscv64-linux-gnu \
--disable-sim
make -j12
make install -j12
cd ..
mkdir gcc_stage1
cd gcc_stage1
rm -rf *
../gcc-11.3.0/configure \
--prefix=${host_root}/usr \
--target=riscv64-linux-gnu \
--with-arch=rv64ima \
--with-abi=lp64 \
--enable-languages=c \
--disable-multilib \
--disable-threads \
--disable-bootstrap \
--disable-libada \
--disable-libsanitizer \
--disable-libssp \
--disable-libquadmath \
--disable-libquadmath-support \
--disable-libgomp \
--disable-libvtv \
--disable-libatomic \
--disable-shared \
--with-build-time-tools=$host_root/usr/bin
make -j12
make install -j12
cd ..
cd linux-5.18.17
make headers_install ARCH=riscv INSTALL_HDR_PATH=$target_root/usr -j12
cd ..
mkdir glibc_build
cd glibc_build
rm -rf *
CC="$host_root/usr/bin/riscv64-linux-gnu-gcc -march=rv64ima -mabi=lp64" \
CXX="$host_root/usr/bin/riscv64-linux-gnu-g++ -march=rv64ima -mabi=lp64" \
../glibc-2.35/configure \
--prefix=/usr \
--host=riscv64-linux-gnu \
--disable-werror \
--with-headers=$target_root/usr/include
make -j12
make install DESTDIR=$target_root -j12
cd ..
mkdir gcc_stage2
cd gcc_stage2
rm -rf *
../gcc-11.3.0/configure \
--prefix=$host_root/usr \
--target=riscv64-linux-gnu \
--with-arch=rv64ima \
--with-abi=lp64 \
--enable-languages=c,c++ \
--disable-multilib \
--disable-bootstrap \
--with-sysroot=$host_root/usr/../riscv64_target_root \
--with-build-time-tools=$host_root/usr/bin
make -j12
make install -j12
cd ..