-
-
Notifications
You must be signed in to change notification settings - Fork 312
/
Dockerfile
274 lines (208 loc) · 7.01 KB
/
Dockerfile
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#############################
# Selfie Docker Image #
# selfie.cs.uni-salzburg.at #
#############################
#####################################
# RISCV gnu toolchain builder image #
#####################################
FROM ubuntu:23.04 AS riscvgnutoolchainbuilder
ENV TOP=/opt RISCV=/opt/riscv PATH=$PATH:/opt/riscv/bin
WORKDIR $TOP
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev \
libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc \
zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev \
&& apt clean
RUN git clone https://github.com/riscv/riscv-gnu-toolchain
ENV MAKEFLAGS=-j4
RUN cd riscv-gnu-toolchain \
&& ./configure --prefix=$RISCV --enable-multilib \
&& make
###################################
# PK (Proxy kernel) builder image #
###################################
FROM ubuntu:23.04 AS pkbuilder
ENV TOP=/opt RISCV=/opt/riscv PATH=$PATH:/opt/riscv/bin
WORKDIR $TOP
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
make git \
gcc-riscv64-linux-gnu libc-dev-riscv64-cross \
&& apt clean
RUN git clone https://github.com/riscv/riscv-pk
# COPY --from=riscvgnutoolchainbuilder $RISCV/ $RISCV/
ENV MAKEFLAGS=-j4
# moving the compiled binaries from riscv64-linux-gnu to riscv64-unknown-elf
# because spike looks for riscv64-unknown-elf by default when running pk
RUN mkdir -p riscv-pk/build \
&& cd riscv-pk/build \
&& ../configure --prefix=$RISCV --host=riscv64-linux-gnu --with-arch=rv64imafdc_zifencei --with-abi=lp64d \
&& make \
&& make install \
&& mv $RISCV/riscv64-linux-gnu $RISCV/riscv64-unknown-elf
#######################################
# Spike (ISA simulator) builder image #
#######################################
FROM ubuntu:23.04 AS spikebuilder
ENV TOP=/opt RISCV=/opt/riscv PATH=$PATH:/opt/riscv/bin
WORKDIR $TOP
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
make git \
g++ device-tree-compiler libboost-regex-dev libboost-system-dev \
&& apt clean
RUN git clone https://github.com/riscv/riscv-isa-sim
ENV MAKEFLAGS=-j4
RUN mkdir -p riscv-isa-sim/build \
&& cd riscv-isa-sim/build \
&& ../configure --prefix=$RISCV \
&& make \
&& make install
######################
# QEMU builder image #
######################
FROM ubuntu:23.04 AS qemubuilder
ENV TOP=/opt RISCV=/opt/riscv PATH=$PATH:/opt/riscv/bin
WORKDIR $TOP
# install statically linked QEMU (so it's easier to move it to another image)
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
qemu-user-static qemu-system-misc \
&& apt clean
# copy QEMU RISC-V statically linked binary to common output folder
RUN mkdir -p $RISCV/bin \
&& cp /usr/bin/qemu-riscv64-static $RISCV/bin \
&& cp /usr/bin/qemu-system-riscv64 $RISCV/bin \
&& cp /usr/bin/qemu-riscv32-static $RISCV/bin \
&& cp /usr/bin/qemu-system-riscv32 $RISCV/bin
########################################
# Boolector (SMT solver) builder image #
########################################
FROM ubuntu:23.04 AS boolectorbuilder
ENV TOP=/opt RISCV=/opt/riscv PATH=$PATH:/opt/riscv/bin
WORKDIR $TOP
# Setting non-interactive mode
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
# install tools to build boolector
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
make git \
g++ \
curl cmake \
&& apt clean
RUN git clone https://github.com/Boolector/boolector
ENV MAKEFLAGS=-j4
# build boolector and dependencies
RUN mkdir -p $RISCV \
&& cd boolector \
&& ./contrib/setup-lingeling.sh \
&& ./contrib/setup-btor2tools.sh \
&& ./configure.sh --prefix $RISCV \
&& cd build \
&& make \
&& make install
#######################################
# Bitwuzla (SMT solver) builder image #
#######################################
FROM ubuntu:23.04 AS bitwuzlabuilder
ENV TOP=/opt RISCV=/opt/riscv PATH=$PATH:/opt/riscv/bin
WORKDIR $TOP
# Setting non-interactive mode
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
# install tools to build bitwuzla
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
make git \
g++ \
pkg-config cmake meson libgmp-dev \
&& apt clean
RUN git clone https://github.com/bitwuzla/bitwuzla
ENV MAKEFLAGS=-j4
# build bitwuzla and dependencies
RUN mkdir -p $RISCV \
&& cd bitwuzla \
&& ./configure.py --prefix $RISCV \
&& cd build \
&& ninja install
#########################
# OpenOCD builder image #
#########################
FROM ubuntu:23.04 AS openocdbuilder
ENV TOP=/opt RISCV=/opt/riscv PATH=$PATH:/opt/riscv/bin
WORKDIR $TOP
# install tools to build OpenOCD
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
make git \
gcc libtool libusb-dev \
automake pkg-config \
&& apt clean
RUN git clone https://github.com/riscv/riscv-openocd.git
ENV MAKEFLAGS=-j4
RUN mkdir -p $RISCV \
&& cd riscv-openocd \
&& ./bootstrap \
&& ./configure \
--prefix=$RISCV \
--program-prefix=riscv64- \
&& make \
&& make install
############################
# Selfie interactive image #
############################
FROM ubuntu:23.04 AS selfieall
ENV TOP=/opt RISCV=/opt/riscv PATH=$PATH:/opt/riscv/bin
WORKDIR $TOP
# Setting non-interactive mode
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
# install tools for selfie
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
make git \
gcc gdb libc6-dev-i386-amd64-cross \
python3 \
device-tree-compiler gcc-riscv64-linux-gnu \
&& apt-get install -y --no-install-recommends \
binutils-riscv64-linux-gnu libc-dev-riscv64-cross \
libusb-dev libhidapi-dev \
xxd gettext curl \
&& apt clean
# copy spike, pk, qemu and boolector from builder images
COPY --from=pkbuilder $RISCV/ $RISCV/
COPY --from=spikebuilder $RISCV/ $RISCV/
COPY --from=qemubuilder $RISCV/ $RISCV/
COPY --from=boolectorbuilder $RISCV/ $RISCV/
COPY --from=bitwuzlabuilder $RISCV/ $RISCV/
COPY --from=openocdbuilder $RISCV/ $RISCV/
# add selfie sources to the image
COPY . /opt/selfie/
# specify user work directory
WORKDIR /opt/selfie
# test build, then clean selfie
RUN make selfie \
&& make clean
# default command
CMD /bin/bash
#################################
# Selfie interactive full image #
#################################
FROM selfieall AS selfieeverything
# only works on amd64 for now
# install tools for 32-bit selfie
RUN apt-get update \
&& apt-get install -y --no-install-recommends lib32gcc-13-dev lib32gcc-12-dev \
&& apt clean
# specify user work directory
WORKDIR /opt/selfie
# build baremetal machine files
RUN make --directory machine/
# default command
CMD /bin/bash