forked from cksystemsteaching/selfie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-riscv-tools
79 lines (67 loc) · 1.6 KB
/
Dockerfile-riscv-tools
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
# builder image
FROM ubuntu:16.04 AS builder
# specify work directory and RISC-V install directory
ENV TOP /opt
ENV RISCV $TOP/riscv
ENV PATH $PATH:$RISCV/bin
WORKDIR $TOP
# install tools to build RISC-V gnu toolchain, spike and pk
RUN apt-get update && apt-get install -y \
autoconf \
automake \
autotools-dev \
curl \
device-tree-compiler \
libmpc-dev \
libmpfr-dev \
libgmp-dev \
libusb-1.0-0-dev \
gawk \
build-essential \
bison \
flex \
texinfo \
gperf \
libtool \
patchutils \
bc \
zlib1g-dev \
device-tree-compiler \
pkg-config \
libexpat-dev \
git \
gcc
# get sources from HEAD
RUN git clone https://github.com/riscv/riscv-tools.git \
&& cd riscv-tools \
&& git submodule update --init --recursive
# build everything with gcc
RUN mkdir -p $RISCV \
&& cd riscv-tools \
&& CC=gcc CXX=g++ ./build.sh
# test the RISC-V gnu toolchain
RUN echo '#include <stdio.h>\n int main(void) { printf("Hello world!\\n"); return 0; }' > hello.c \
&& riscv64-unknown-elf-gcc -o hello hello.c \
&& spike pk hello
# remove RISC-V gnu toolchain to shrink image size
RUN rm -rf \
riscv/bin/riscv64-* \
riscv/bin/openocd \
riscv/lib/gcc \
riscv/libexec \
riscv/share
# release image
FROM ubuntu:16.04
# specify work directory and RISC-V install directory
ENV TOP /opt
ENV RISCV $TOP/riscv
ENV PATH $PATH:$RISCV/bin
WORKDIR $TOP
# install gcc, make and diff
RUN apt-get update && apt-get install -y \
device-tree-compiler \
build-essential \
gcc \
&& rm -rf /var/lib/apt/lists/*
# copy spike and pk from builder image
COPY --from=builder $RISCV/ $RISCV/