-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild-kvx-xgcc.sh
executable file
·126 lines (105 loc) · 2.57 KB
/
build-kvx-xgcc.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
#!/usr/bin/env bash
set -eu
## Set these for using specific revision
SHA1_GCC=${SHA1_GCC:-HEAD}
SHA1_BINUTILS=${SHA1_BINUTILS:-HEAD}
SHA1_NEWLIB=${SHA1_NEWLIB:-HEAD}
TARGET=${TARGET:-kvx-elf}
PREFIX=$(realpath "$1")
PARALLEL_JOBS=-j6
mkdir -p "$PREFIX"
export PATH="$PREFIX/bin:$PATH"
function git_clone() {
local repo=$1
local sha1=$2
local branch=$3
if [[ "${branch}" == "-" ]];
then
branch=""
else
branch="-b ${branch}"
fi
repo_dir=$(basename "${repo}" ".git")
echo "Cloning ${repo} (${repo_dir}) sha1: ${sha1}"
if [ -d "${repo_dir}" ]; then
(
cd "${repo_dir}"
git fetch
)
else
git clone ${branch} "${repo}"
fi
if [[ ! -z "${sha1}" ]]
then
(
cd "${repo_dir}"
git reset --hard "${sha1}"
)
fi
}
git_clone https://github.com/kalray/binutils.git "${SHA1_BINUTILS}" -
git_clone https://github.com/kalray/newlib.git "${SHA1_NEWLIB}" coolidge
git_clone https://github.com/kalray/gcc.git "${SHA1_GCC}" coolidge
mkdir -p build-binutils
pushd build-binutils
$PWD/../binutils/configure \
--prefix="$PREFIX" \
--target="$TARGET" \
--disable-initfini-array \
--disable-gdb \
--without-gdb \
--disable-werror \
--with-expat=yes \
--with-babeltrace=no \
--with-bugurl=no
make all "$PARALLEL_JOBS" > /dev/null
make install-strip
popd
pushd gcc
## This is used only when distribution does not have correct dependencies.
if [ -e /etc/os-release ] ; then
if grep -q "CentOS Linux 7" /etc/os-release; then
./contrib/download_prerequisites
fi
fi
popd
mkdir -p build-gcc
pushd build-gcc
$PWD/../gcc/configure \
--prefix="$PREFIX" \
--target="$TARGET" \
--with-gnu-as \
--with-gnu-ld \
--disable-bootstrap \
--disable-shared \
--enable-multilib \
--disable-libmudflap \
--disable-libssp \
--enable-__cxa_atexit \
--with-bugurl=no \
--with-newlib \
--disable-libgomp \
--disable-libatomic \
--disable-threads \
--enable-languages=c,c++ \
--with-system-zlib
make all-gcc "$PARALLEL_JOBS" > /dev/null
make install-strip-gcc
popd
mkdir -p build-newlib
pushd build-newlib
$PWD/../newlib/configure \
--target="$TARGET" \
--prefix="$PREFIX" \
--enable-multilib \
--enable-target-optspace \
--enable-newlib-io-c99-formats \
--enable-newlib-multithread
make all "$PARALLEL_JOBS" > /dev/null
make install
popd
pushd build-gcc
make all "$PARALLEL_JOBS" > /dev/null
make install-strip
popd
echo "Finished"