/
sel4.sh
201 lines (183 loc) · 6.63 KB
/
sel4.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/bin/bash
#
# Copyright 2020, Data61/CSIRO
#
# SPDX-License-Identifier: BSD-2-Clause
#
set -exuo pipefail
# Source common functions
DIR="${BASH_SOURCE%/*}"
test -d "$DIR" || DIR=$PWD
# shellcheck source=utils/common.sh
. "$DIR/utils/common.sh"
# Don't make caches by default. Docker will set this to be 'yes'
: "${MAKE_CACHES:=no}"
# By default, assume we are on a desktop (usually less destructive)
: "${DESKTOP_MACHINE:=yes}"
# Docker may set this variable - fill if not set
: "${SCM:=https://github.com}"
# tmp space for building
: "${TEMP_DIR:=/tmp}"
X64_CROSS="g++-10-aarch64-linux-gnu gcc-10-aarch64-linux-gnu gcc-10-multilib"
ARM64_CROSS="gcc-10-x86-64-linux-gnu:arm64 g++-10-x86-64-linux-gnu:arm64 \
gcc-10-i686-linux-gnu:arm64 g++-10-i686-linux-gnu:arm64"
# TARGETPLATFORM is set by docker during the build process
if [ "$TARGETPLATFORM" = "linux/amd64" ]; then
CROSS="$X64_CROSS"
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then
CROSS="$ARM64_CROSS"
else
echo "Unknown target platform $TARGETPLATFORM"
exit 1
fi
# Add additional architectures for cross-compiled libraries.
# Install the tools required to compile seL4.
as_root apt-get update -q
as_root dpkg --add-architecture amd64
as_root dpkg --add-architecture i386
as_root dpkg --add-architecture armhf
as_root dpkg --add-architecture armel
as_root dpkg --add-architecture arm64
# shellcheck disable=SC2086
as_root apt-get install -y --no-install-recommends \
astyle=3.1-2+b1 \
build-essential \
ccache \
cmake \
cmake-curses-gui \
coreutils \
cpio \
curl \
device-tree-compiler \
doxygen \
libarchive-dev \
libcc1-0 \
libncurses-dev \
libuv1 \
libxml2-utils \
locales \
ninja-build \
protobuf-compiler \
python3-protobuf \
qemu-system-x86 \
sloccount \
u-boot-tools \
clang-11 \
g++-10 \
g++-10-arm-linux-gnueabi \
g++-10-arm-linux-gnueabihf \
gcc-10 \
gcc-10-arm-linux-gnueabi \
gcc-10-arm-linux-gnueabihf \
gcc-10-base \
gcc-riscv64-unknown-elf \
libclang-11-dev \
qemu-system-arm \
qemu-system-misc \
$CROSS
# end of list
if [ "$DESKTOP_MACHINE" = "no" ] ; then
compiler_version=10
# Set default compiler to be gcc-$compiler_version using update-alternatives
# This is necessary particularly for the cross-compilers, which don't put
# a genericly named version of themselves in the PATH.
for compiler in gcc \
g++ \
# end of list
do
for file in $(dpkg-query -L ${compiler} | grep /usr/bin/); do
name=$(basename "$file")
echo "$name - $file"
as_root update-alternatives --install "$file" "$name" "$file-$compiler_version" 50 || : # don't stress if it doesn't work
as_root update-alternatives --auto "$name" || :
done
done
if [ "$TARGETPLATFORM" = "linux/amd64" ]; then
MORE_COMP=""
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then
MORE_COMP="gcc-${compiler_version}-x86-64-linux-gnu \
cpp-${compiler_version}-x86-64-linux-gnu \
g++-${compiler_version}-x86-64-linux-gnu \
gcc-${compiler_version}-i686-linux-gnu \
cpp-${compiler_version}-i686-linux-gnu \
g++-${compiler_version}-i686-linux-gnu \
"
else
echo "Unknown target platform $TARGETPLATFORM"
exit 1
fi
# shellcheck disable=SC2086
for compiler in gcc-${compiler_version}-arm-linux-gnueabi \
cpp-${compiler_version}-arm-linux-gnueabi \
g++-${compiler_version}-arm-linux-gnueabi \
gcc-${compiler_version}-aarch64-linux-gnu \
cpp-${compiler_version}-aarch64-linux-gnu \
g++-${compiler_version}-aarch64-linux-gnu \
gcc-${compiler_version}-arm-linux-gnueabihf \
cpp-${compiler_version}-arm-linux-gnueabihf \
g++-${compiler_version}-arm-linux-gnueabihf \
$MORE_COMP
# end of list
do
echo "${compiler}"
for file in $(dpkg-query -L "${compiler}" | grep /usr/bin/); do
name=$(basename "$file" | sed "s/-${compiler_version}\$//g")
# shellcheck disable=SC2001
link=$(echo "$file" | sed "s/-${compiler_version}\$//g")
echo "$name - $file"
(
as_root update-alternatives --install "${link}" "${name}" "${file}" 60 && \
as_root update-alternatives --auto "${name}"
) || : # Don't worry if this fails
done
done
# Ensure that clang-11 shows up as clang
for compiler in clang \
clang++ \
# end of list
do
as_root update-alternatives --install /usr/bin/"$compiler" "$compiler" "$(which "$compiler"-11)" 60 && \
as_root update-alternatives --auto "$compiler"
done
# Do a quick check to make sure it works:
clang --version
fi
# Get seL4 python3 deps
# Pylint is for checking included python scripts
# Setuptools sometimes is a bit flaky, so double checking it is installed here
as_root pip3 install --no-cache-dir \
setuptools
as_root pip3 install --no-cache-dir \
pylint \
sel4-deps
# end of list
if [ "$MAKE_CACHES" = "yes" ] ; then
# Build seL4test for a few platforms to populate binary artifact caches.
# This should improve build times by caching libraries that rarely change.
mkdir -p ~/.sel4_cache
try_nonroot_first mkdir -p "$TEMP_DIR/sel4test" || chown_dir_to_user "$TEMP_DIR/sel4test"
pushd "$TEMP_DIR/sel4test"
repo init -u "${SCM}/seL4/sel4test-manifest.git" --depth=1
repo sync -j 4
mkdir build
pushd build
for plat in "sabre" "ia32" "x86_64" "tx1" "tk1 -DARM_HYP=ON"; do
# shellcheck disable=SC2086 # no "" around plat, so HYP still works
../init-build.sh -DPLATFORM=$plat
ninja
rm -rf ./*
done
popd
popd
rm -rf sel4test
fi
if [ "$DESKTOP_MACHINE" = "no" ] ; then
# Set up locales. en_AU chosen because we're in Australia.
echo 'en_AU.UTF-8 UTF-8' | as_root tee /etc/locale.gen > /dev/null
as_root dpkg-reconfigure --frontend=noninteractive locales
echo "LANG=en_AU.UTF-8" | as_root tee -a /etc/default/locale > /dev/null
echo "export LANG=en_AU.UTF-8" >> "$HOME/.bashrc"
fi
# If we have been using Debian Snapshot, then we need to switch
# back to using the normal apt repos, for anyone using the image after this point.
possibly_toggle_apt_snapshot