-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathbuild_elf_toolchain.sh
executable file
·112 lines (97 loc) · 3.24 KB
/
build_elf_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
TARGET=riscv32-elf
PREFIX=`pwd`/nds32le-elf-newlib-v5
ARCH=rv32imcxandes
ABI=ilp32
CPU=andes-25-series
BUILD=`pwd`/build-nds32le-elf-newlib-v5
BINUTILS_SRC=`pwd`/binutils
GDB_SRC=`pwd`/gdb
GCC_SRC=`pwd`/gcc
NEWLIB_SRC=`pwd`/newlib
MAKE_PARALLEL=-j`nproc`
#MAKE_PARALLEL=-j1
mkdir ${BUILD}
# 00. Prepare
export PATH=${PREFIX}/bin:$PATH
cd ${GCC_SRC}
./contrib/download_prerequisites
cd -
cd ${BUILD}
# 01. Binutils
mkdir -p binutils
cd binutils
${BINUTILS_SRC}/configure \
--target=${TARGET} --prefix=${PREFIX} --with-arch=${ARCH} \
--with-curses --disable-nls --disable-tui --with-python=no --with-lzma=no \
--with-expat=yes --with-guile=no --enable-plugins --disable-werror \
--enable-deterministic-archives --disable-gdb --disable-sim \
--enable-multilib=yes --with-multilib-list=dsp
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
make ${MAKE_PARALLEL} all
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
make install
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
cd ..
# 02. Bootstrap GCC
mkdir -p bootstrap-gcc
cd bootstrap-gcc
${GCC_SRC}/configure \
--prefix=${PREFIX} --with-arch=${ARCH} --with-tune=${CPU} --target=${TARGET} \
--disable-nls --enable-languages=c --enable-lto \
--enable-Os-default-ex9=yes --enable-gp-insn-relax-default=yes \
--enable-error-on-no-atomic=yes --disable-tls \
--enable-multilib=yes --with-multilib-list=dsp \
--with-newlib --with-abi=${ABI} --disable-werror \
--disable-shared --enable-threads=single \
--enable-checking=release \
CFLAGS_FOR_TARGET="-O2 -g -mstrict-align" \
CXXFLAGS_FOR_TARGET="-O2 -g -mstrict-align"
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
make ${MAKE_PARALLEL} all-gcc
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
make install-gcc
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
cd ..
# 03. Newlib
mkdir -p newlib
cd newlib
${NEWLIB_SRC}/configure --prefix=${PREFIX} --target=${TARGET} \
CFLAGS_FOR_TARGET="-O2 -ffunction-sections -fdata-sections -mstrict-align"
make ${MAKE_PARALLEL} all
make install
cd ..
# 04. Final GCC
mkdir -p final-gcc
cd final-gcc
${GCC_SRC}/configure \
--prefix=${PREFIX} --with-arch=${ARCH} --with-tune=${CPU} --target=${TARGET} \
--disable-nls --enable-languages=c,c++ --enable-lto --with-abi=${ABI} \
--enable-Os-default-ex9=yes --enable-gp-insn-relax-default=yes \
--enable-error-on-no-atomic=yes --disable-tls \
--enable-multilib=yes --with-multilib-list=dsp \
--with-newlib --disable-shared --enable-threads=single \
--disable-werror --with-headers=${PREFIX}/${TARGET}/include \
--enable-checking=release \
CFLAGS_FOR_TARGET="-O2 -g -mstrict-align" \
CXXFLAGS_FOR_TARGET="-O2 -g -mstrict-align"
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
make ${MAKE_PARALLEL} all
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
make install
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
cd ..
# 5. GDB
mkdir -p gdb
cd gdb
${GDB_SRC}/configure \
--target=${TARGET} --prefix=${PREFIX} --with-arch=${ARCH} \
--with-curses --disable-nls --enable-tui --with-python=no \
--with-lzma=no --with-expat=yes --with-guile=no \
--disable-werror --enable-sim \
--disable-binutils --disable-ld --disable-gas --disable-gprof
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
make ${MAKE_PARALLEL} all
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
make install
rc=$?; if [[ $rc != 0 ]]; then exit $rc; fi
cd ..