-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
354 lines (320 loc) · 10.8 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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# Copyright 2021, 2022, 2023 Galois, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Base
FROM ubuntu:22.04 as base
ARG DEBIAN_FRONTEND=noninteractive
RUN mkdir /tools
WORKDIR /
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y wget git python3 pip \
python3-dev software-properties-common \
iproute2 usbutils srecord \
build-essential clang bison flex \
libreadline-dev gawk tcl-dev libffi-dev git \
graphviz xdot pkg-config python3 libboost-system-dev \
libboost-python-dev libboost-filesystem-dev zlib1g-dev \
libboost-all-dev python3-pip \
cmake openocd \
libeigen3-dev qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools \
autoconf automake autotools-dev curl libmpc-dev \
libmpfr-dev libgmp-dev texinfo gperf \
libtool patchutils bc zlib1g-dev libexpat-dev \
libftdi-dev unzip libffi7 \
libftdi1-2 libftdi1-dev libhidapi-libusb0 libhidapi-dev libudev-dev make g++ \
libc++-dev libc++abi-dev nodejs python2 npm \
iverilog verilator \
vim mercurial libboost-program-options-dev \
texlive-full pandoc
# Builder
FROM base as builder
ARG VERSION_LOG=/tools/log.txt
RUN echo "Installed tools:" >> ${VERSION_LOG}
# Yosys
ARG TOOL=yosys
ARG TAG=yosys-0.17
ARG REPO=https://github.com/YosysHQ/yosys.git
RUN git clone ${REPO} /tmp/${TOOL}
WORKDIR /tmp/${TOOL}
RUN \
git checkout ${TAG} \
&& make -j$(nproc) \
&& make install PREFIX=/opt
RUN echo "${TOOL} ${REPO} ${TAG}" >> ${VERSION_LOG}
# Trellis
ARG TOOL=prjtrellis
ARG TAG=1.2.1
ARG REPO=https://github.com/YosysHQ/prjtrellis.git
RUN git clone --recursive ${REPO} /tmp/${TOOL}
WORKDIR /tmp/${TOOL}/libtrellis
RUN \
git checkout ${TAG} \
&& cmake -DCMAKE_INSTALL_PREFIX=/opt . \
&& make -j$(nproc) \
&& make install
ENV TRELLIS="/opt/share/trellis"
RUN echo "${TOOL} ${REPO} ${TAG}" >> ${VERSION_LOG}
# nextpnr
ARG TOOL=nextpnr
ARG TAG=nextpnr-0.3
ARG REPO=https://github.com/YosysHQ/nextpnr.git
RUN git clone ${REPO} /tmp/${TOOL}
WORKDIR /tmp/${TOOL}
RUN \
git checkout ${TAG} \
&& cmake . -DARCH=ecp5 -DTRELLIS_INSTALL_PREFIX=/opt \
&& make -j$(nproc) \
&& make install
RUN echo "${TOOL} ${REPO} ${TAG}" >> ${VERSION_LOG}
# RISCV toolchain
ARG TOOL=riscv-gnu-toolchain
ARG TAG=2022.01.17
ARG REPO=https://github.com/riscv/riscv-gnu-toolchain
RUN git clone --recursive ${REPO} /tmp/${TOOL}
WORKDIR /tmp/${TOOL}
RUN \
git checkout ${TAG} \
&& ./configure --prefix=/opt/riscv --enable-multilib \
&& export MAKEFLAGS="-j$(nproc)" \
&& make \
&& make linux
ENV PATH="/opt/riscv/bin:/opt/bin:${PATH}"
RUN echo "${TOOL} ${REPO} ${TAG}" >> ${VERSION_LOG}
# ecpprog
ARG TOOL=ecpprog
ARG TAG=7212b56a9d2fc6de534e06636a1c6d8b0c6f80ab
ARG REPO=https://github.com/gregdavill/ecpprog
RUN git clone ${REPO} /tmp/${TOOL}
WORKDIR /tmp/${TOOL}/ecpprog
RUN \
git checkout ${TAG} \
&& make -j$(nproc) \
&& make install
RUN echo "${TOOL} ${REPO} ${TAG}" >> ${VERSION_LOG}
# Iverilog
RUN echo "`iverilog -v | head -1`" >> ${VERSION_LOG}
# Bluespec compiler
ARG TOOL=bluespec-compiler
ARG TAG=bsc-2021.07-ubuntu-20.04
ARG REPO=https://github.com/B-Lang-org/bsc
WORKDIR /tmp
RUN \
wget ${REPO}/releases/download/2021.07/${TAG}.tar.gz \
&& tar xvzf ${TAG}.tar.gz \
&& mv ${TAG} /tools/${TAG} \
&& rm ${TAG}.tar.gz
ENV PATH="/tools/${TAG}/bin:${PATH}"
RUN echo "${TOOL} ${REPO} ${TAG}" >> ${VERSION_LOG}
# Verilator
RUN echo "`verilator --version`" >> ${VERSION_LOG}
# OpenFPGAloader
ARG TOOL=openFPGALoader
ARG TAG=v0.7.0
ARG REPO=https://github.com/trabucayre/openFPGALoader.git
RUN \
git clone ${REPO} /tmp/${TOOL} \
&& cd /tmp/${TOOL} \
&& git checkout ${TAG}
RUN mkdir /tmp/${TOOL}/build
WORKDIR /tmp/${TOOL}/build
RUN \
cmake ../ \
&& cmake --build . \
&& make install
RUN echo "${TOOL} ${REPO} ${TAG}" >> ${VERSION_LOG}
# NOTE: these might be necessary for properly connecting USB devices
#WORKDIR /tools/${TOOL}
#RUN cp 99-openfpgaloader.rules /etc/udev/rules.d/
#RUN udevadm control --reload-rules && sudo udevadm trigger
#RUN usermod -a $USER -G plugdev
# elf2hex
ARG TOOL=elf2hex
ARG TAG=v20.08.00.00
ARG REPO=https://github.com/sifive/elf2hex.git
RUN git clone ${REPO} /tmp/${TOOL}
WORKDIR /tmp/${TOOL}
RUN \
git checkout ${TAG} \
&& autoreconf -i \
&& ./configure --target=riscv64-unknown-elf \
&& make \
&& make install
RUN echo "${TOOL} ${REPO} ${TAG}" >> ${VERSION_LOG}
# Bluespec libraries
ARG TOOL=bsc-contrib
ARG TAG=aa205330885f6955e24fd99a0319e2733b5353f1
ARG REPO=https://github.com/B-Lang-org/bsc-contrib.git
RUN git clone ${REPO} /tools/${TOOL}
WORKDIR /tools/${TOOL}
RUN \
git checkout ${TAG} \
&& make PREFIX=/tools/bsc-2021.07-ubuntu-20.04/
RUN echo "${TOOL} ${REPO} ${TAG}" >> ${VERSION_LOG}
# GHC and Cabal
RUN \
wget https://downloads.haskell.org/~ghcup/x86_64-linux-ghcup -O /usr/local/bin/ghcup \
&& chmod +x /usr/local/bin/ghcup
ENV PATH="/root/.ghcup/bin:${PATH}"
RUN \
ghcup install ghc 8.10.7 \
&& ghcup set ghc 8.10.7 \
&& ghcup install cabal
RUN cabal update
# cryptol 2.11
ARG TOOL=cryptol
ARG TAG=dfae4580e322584185235f301bc8a03b6bc19a65
ARG REPO=https://github.com/GaloisInc/cryptol.git
RUN git clone ${REPO} /tmp/${TOOL}
WORKDIR /tmp/${TOOL}
# Build fix
RUN echo "constraints:" > cabal.project.local
RUN echo " parameterized-utils < 2.1.6" >> cabal.project.local
RUN \
git checkout ${TAG} \
&& git submodule update --init \
&& ./cry build \
&& cabal v2-install --installdir=/tools
RUN echo "${TOOL} ${REPO} ${TAG}" >> ${VERSION_LOG}
# Z3 solver
ARG TOOL=z3
ARG TAG=4.8.14-x64-glibc-2.31
ARG REPO=https://github.com/Z3Prover/z3/releases/download/z3-4.8.14
WORKDIR /tmp
RUN wget ${REPO}/${TOOL}-${TAG}.zip
RUN unzip ${TOOL}-${TAG}.zip
RUN mv ${TOOL}-${TAG} /tools/${TOOL}
ENV PATH="/tools/${TOOL}/bin:${PATH}"
RUN echo "${TOOL} ${REPO} ${TAG}" >> ${VERSION_LOG}
# SAW
ARG TOOL=saw
ARG TAG=e2fef66d7cf4c67ecb86b0fe096977cd7e925183
ARG REPO=https://github.com/GaloisInc/saw-script.git
RUN git clone ${REPO} /tmp/${TOOL}
WORKDIR /tmp/${TOOL}
RUN git checkout ${TAG} \
&& git submodule update --init \
&& ./build.sh \
&& cp bin/saw /usr/local/bin
RUN echo "${TOOL} ${REPO} ${TAG}" >> ${VERSION_LOG}
########################################
# Riscv-formal
#######################################
ARG TOOL=SymbiYosys
ARG TAG=419ef76f82b3973e356815f63fc919218b2860bb
ARG REPO=https://github.com/YosysHQ/SymbiYosys.git
RUN git clone ${REPO} /tmp/${TOOL}
WORKDIR /tmp/${TOOL}
RUN make install
RUN echo "${TOOL} ${REPO} ${TAG}" >> ${VERSION_LOG}
ARG TOOL=yices2
ARG TAG=Yices-2.6.4
ARG REPO=https://github.com/SRI-CSL/yices2.git
RUN git clone ${REPO} /tmp/${TOOL}
WORKDIR /tmp/${TOOL}
RUN autoconf
RUN ./configure
RUN make -j$(nproc)
RUN make install
RUN echo "${TOOL} ${REPO} ${TAG}" >> ${VERSION_LOG}
ARG TOOL=boolector
ARG TAG=3.2.2
ARG REPO=https://github.com/boolector/boolector
RUN git clone ${REPO} /tmp/${TOOL}
WORKDIR /tmp/${TOOL}
RUN ./contrib/setup-btor2tools.sh
RUN ./contrib/setup-lingeling.sh
RUN ./configure.sh
RUN make -C build -j$(nproc)
RUN cp build/bin/boolector /usr/local/bin/
RUN cp build/bin/btor* /usr/local/bin/
RUN cp deps/btor2tools/bin/btorsim /usr/local/bin/
RUN echo "${TOOL} ${REPO} ${TAG}" >> ${VERSION_LOG}
# NuSMV
# wget https://nusmv.fbk.eu/distrib/NuSMV-2.6.0-linux64.tar.gz
# tar xzf NuSMV-2.6.0-linux64.tar.gz
# cp NuSMV-2.6.0-Linux/bin/* /usr/local/bin/
# JKind-1
# wget https://github.com/andreaskatis/jkind-1/releases/download/v2.0/jkind
# wget https://github.com/andreaskatis/jkind-1/releases/download/v2.0/jkind.jar
# wget https://github.com/andreaskatis/jkind-1/releases/download/v2.0/jlustre2kind
# wget https://github.com/andreaskatis/jkind-1/releases/download/v2.0/jrealizability
# chmod 755 jkind jlustre2kind jrealizability
# cp * /usr/local/bin/
# Kind 2
# wget https://github.com/kind2-mc/kind2/releases/download/v1.6.0/kind2-v1.6.0-linux-x86_64.tar.gz
# wget https://github.com/kind2-mc/kind2/releases/download/v1.6.0/user_documentation.pdf
# tar xzf kind2-v1.6.0-linux-x86_64.tar.gz
# mv kind2 /usr/local/bin/
# Fret
# ARG TOOL=fret
# ARG TAG=7dbfbf65d8b7f96e9f1fdca2dd19a2a2387d2674
# ARG REPO=https://github.com/NASA-SW-VnV/fret.git
# RUN git clone ${REPO} /tools/${TOOL}
# WORKDIR /tools/${TOOL}
# RUN git checkout ${TAG} \
# && git submodule update --init
# WORKDIR /tools/${TOOL}/fret-electron
# # Change https://github.com/NASA-SW-VnV/fret/blob/master/fret-electron/package.json#L249 to "redux-thunk": "^2.4.1" and
# # https://github.com/NASA-SW-VnV/fret/blob/master/fret-electron/package.json#L248 to "redux": :^4"
# RUN npm run fret-install
# # NOTE: npm run start still fails, likely because it requires X server which is not availale in Docker
# RUN echo "${TOOL} ${REPO} ${TAG}" >> ${VERSION_LOG}
# Lando/Lobot
ARG TOOL=lando
ARG TAG=428ea1174de2bed7c069a6ef8edb30ca75ed441a
ARG REPO=https://github.com/GaloisInc/BESSPIN-Lando.git
RUN git clone ${REPO} /tools/${TOOL}
WORKDIR /tools/${TOOL}
RUN apt-get install -y maven
RUN ./lando.sh -r
RUN cd /tools/${TOOL}/source/lobot/ && cabal v2-build
ENV PATH="/tools/${TOOL}:${PATH}"
RUN echo "${TOOL} ${REPO} ${TAG}" >> ${VERSION_LOG}
# RDE Refinement Finder (aka the DocumentationEnricher)
ARG TOOL=der
ARG TAG=0.1.5
ARG REPO=https://github.com/GaloisInc/RDE_RF
WORKDIR /tmp
RUN wget ${REPO}/releases/download/v.${TAG}/${TOOL}-${TAG}.zip
RUN unzip ${TOOL}-${TAG}.zip
RUN mv ${TOOL}-${TAG} /tools/${TOOL} && rm ${TOOL}-${TAG}.zip
ENV PATH="/tools/${TOOL}:${PATH}"
RUN echo "${TOOL} ${REPO} ${TAG}" >> ${VERSION_LOG}
# cryptol-verilog
ARG TOOL=cryptol-verilog
COPY ${TOOL} /tmp/${TOOL}
WORKDIR /tmp/${TOOL}
RUN \
cabal v2-build \
&& cabal v2-install --installdir=/tools
# Crymp
ARG TOOL=cryptol-codegen
COPY ${TOOL} /tmp/${TOOL}
WORKDIR /tmp/${TOOL}
RUN \
cabal build \
&& cabal install --installdir=/tools
ENV PATH="/tools/:${PATH}"
# Runner
FROM base as runner
COPY --from=builder /opt/ /opt/
COPY --from=builder /tools/ /tools/
COPY --from=builder /root/.cabal/ /root/.cabal/
COPY --from=builder /usr/local/bin/ /usr/local/bin/
COPY --from=builder /usr/local/lib/python2.7/dist-packages/ /usr/local/lib/python2.7/dist-packages/
COPY --from=builder /usr/local/share/ /usr/local/share/
RUN cat ${VERSION_LOG}
WORKDIR /HARDENS
# Install java so we can run lando
RUN apt-get install -y default-jre
ENV PATH="/tools/der/bin:/tools/lando:/tools:/tools/z3/bin:/tools/bsc-2021.07-ubuntu-20.04/bin:/opt/riscv/bin:/opt/bin:${PATH}"