77FROM ubuntu:20.04
88
99ARG QEMU_VERSION=7.0.0
10+ ARG GDB_VERSION=14.1
1011ARG HOME=/root
1112
1213# 0. Install general tools
1314ARG DEBIAN_FRONTEND=noninteractive
1415RUN apt-get update && \
1516 apt-get install -y \
16- curl \
17- git \
18- python3 \
19- wget
17+ curl \
18+ git \
19+ python3 \
20+ wget
2021
2122# 1. Set up QEMU RISC-V
2223# - https://learningos.github.io/rust-based-os-comp2022/0setup-devel-env.html#qemu
@@ -29,23 +30,33 @@ WORKDIR ${HOME}
2930RUN wget https://download.qemu.org/qemu-${QEMU_VERSION}.tar.xz && \
3031 tar xvJf qemu-${QEMU_VERSION}.tar.xz
3132
33+ RUN wget https://ftp.gnu.org/gnu/gdb/gdb-${GDB_VERSION}.tar.xz && \
34+ tar xvJf gdb-${GDB_VERSION}.tar.xz
35+
3236# 1.2. Install dependencies
3337# - https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html#prerequisites
3438RUN apt-get install -y \
35- autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev \
36- gawk build-essential bison flex texinfo gperf libtool patchutils bc \
37- zlib1g-dev libexpat-dev git \
38- ninja-build pkg-config libglib2.0-dev libpixman-1-dev libsdl2-dev
39+ autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev \
40+ gawk build-essential bison flex texinfo gperf libtool patchutils bc \
41+ zlib1g-dev libexpat-dev git \
42+ ninja-build pkg-config libglib2.0-dev libpixman-1-dev libsdl2-dev \
43+ libncurses5-dev python2 python2-dev libreadline-dev tmux
44+
3945
4046# 1.3. Build and install from source
4147WORKDIR ${HOME}/qemu-${QEMU_VERSION}
4248RUN ./configure --target-list=riscv64-softmmu,riscv64-linux-user && \
4349 make -j$(nproc) && \
4450 make install
4551
52+ WORKDIR ${HOME}/gdb-${GDB_VERSION}
53+ RUN ./configure --prefix=/usr/local --target=riscv64-unknown-elf --enable-tui=yes && \
54+ make -j$(nproc) && \
55+ make install
56+
4657# 1.4. Clean up
4758WORKDIR ${HOME}
48- RUN rm -rf qemu-${QEMU_VERSION} qemu-${QEMU_VERSION}.tar.xz
59+ RUN rm -rf qemu-${QEMU_VERSION} qemu-${QEMU_VERSION}.tar.xz ${HOME}/gdb-${GDB_VERSION} gdb-${GDB_VERSION}.tar.xz
4960
5061# 1.5. Sanity checking
5162RUN qemu-system-riscv64 --version && \
@@ -73,13 +84,5 @@ RUN rustup --version && \
7384 cargo --version && \
7485 rustc --version
7586
76- # 3. Build env for labs
77- # See os1/Makefile `env:` for example.
78- # This avoids having to wait for these steps each time using a new container.
79- RUN rustup target add riscv64gc-unknown-none-elf && \
80- cargo install cargo-binutils --vers ~0.2 && \
81- rustup component add rust-src && \
82- rustup component add llvm-tools-preview
83-
8487# Ready to go
8588WORKDIR ${HOME}
0 commit comments