Skip to content

Commit 8f9f992

Browse files
committed
tools/docker: add rust compiler
Add the new dependencies necessary for generating RUST=y Linux configs and for building RUST=y kernels.
1 parent b84f053 commit 8f9f992

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

tools/docker/env/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,20 @@ RUN chmod 0777 /syzkaller
112112
ENV SOURCEDIR_FUCHSIA /syzkaller/fuchsia
113113
ENV SOURCEDIR_NETBSD /syzkaller/netbsd
114114

115+
# Rust toolchain for kernel builds.
116+
ENV RUSTUP_HOME=/usr/local/rustup
117+
ENV CARGO_HOME=/usr/local/cargo
118+
ENV PATH=/usr/local/cargo/bin:$PATH
119+
ENV RUST_VERSION=1.87.0
120+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUST_VERSION
121+
RUN rustup component add rust-src
122+
RUN cargo install --locked bindgen-cli
123+
124+
# Use the latest libdw-dev release, otherwise we get compilation error when CONFIG_RUST=y.
125+
RUN echo "deb http://deb.debian.org/debian bookworm-backports main contrib non-free non-free-firmware" > /etc/apt/sources.list.d/bookworm-backports.list
126+
RUN apt-get update
127+
RUN apt-get install -y --no-install-recommends libdw-dev/bookworm-backports libelf-dev/bookworm-backports
128+
115129
# Install node to pass act jobs (https://github.com/nektos/act)
116130
RUN apt-get install -y -q nodejs
117131

tools/docker/syzbot/Dockerfile

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q \
1313
unzip curl sudo procps psmisc nano vim git bzip2 dh-autoreconf software-properties-common \
1414
# These are needed to build Linux kernel:
1515
flex bison bc gawk dwarves cpio texinfo texi2html lzop lbzip2 \
16-
zlib1g-dev libelf-dev libncurses-dev libmpc-dev libssl-dev \
16+
zlib1g-dev libncurses-dev libmpc-dev libssl-dev \
1717
apt-transport-https curl gnupg python-is-python3 \
1818
# Needed for building Cuttlefish images.
1919
rsync libarchive-tools \
@@ -22,9 +22,7 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q \
2222
util-linux dosfstools ocfs2-tools reiserfsprogs xfsprogs erofs-utils \
2323
exfatprogs gfs2-utils \
2424
# Needed for buiding gVisor.
25-
crossbuild-essential-amd64 crossbuild-essential-arm64 libbpf-dev \
26-
# Needed for CONFIG_GENDWARFKSYMS.
27-
libdw-dev
25+
crossbuild-essential-amd64 crossbuild-essential-arm64 libbpf-dev
2826
RUN test "$(uname -m)" != x86_64 && exit 0 || \
2927
DEBIAN_FRONTEND=noninteractive apt-get install -y -q \
3028
libc6-dev-i386 libc6-dev-i386-amd64-cross lib32gcc-12-dev lib32stdc++-12-dev \
@@ -83,6 +81,20 @@ RUN test "$(uname -m)" != x86_64 && exit 0 || \
8381
DEBIAN_FRONTEND=noninteractive apt-get install -t bookworm-backports -y -q \
8482
qemu-system-s390x qemu-system-mips qemu-system-ppc
8583

84+
# Rust toolchain for kernel builds.
85+
ENV RUSTUP_HOME=/usr/local/rustup
86+
ENV CARGO_HOME=/usr/local/cargo
87+
ENV PATH=/usr/local/cargo/bin:$PATH
88+
ENV RUST_VERSION=1.87.0
89+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUST_VERSION
90+
RUN rustup component add rust-src
91+
RUN cargo install --locked bindgen-cli
92+
93+
# Use the latest libdw-dev release, otherwise we get compilation error when CONFIG_RUST=y.
94+
RUN echo "deb http://deb.debian.org/debian bookworm-backports main contrib non-free non-free-firmware" > /etc/apt/sources.list.d/bookworm-backports.list
95+
RUN apt-get update
96+
RUN apt-get install -y --no-install-recommends libdw-dev/bookworm-backports libelf-dev/bookworm-backports
97+
8698
# Install gcloud https://cloud.google.com/sdk/docs/install#deb.
8799
RUN apt-get install -y -q ca-certificates \
88100
&& curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg \

0 commit comments

Comments
 (0)