|
| 1 | +{% extends 'clang-15.jinja2' %} |
| 2 | + |
| 3 | +{% block packages %} |
| 4 | +{{ super() }} |
| 5 | + |
| 6 | +ARG RUST_VER=1.66.0 |
| 7 | +ARG BINDGEN_VER=0.56.0 |
| 8 | + |
| 9 | +ARG RUST_TRIPLE=rust-${RUST_VER}-x86_64-unknown-linux-gnu |
| 10 | + |
| 11 | +ENV CARGO_HOME=/home/kernelci/.cargo |
| 12 | +ENV PATH=/usr/${RUST_TRIPLE}/bin:${CARGO_HOME}/bin:${PATH} |
| 13 | + |
| 14 | +ARG SHA256SUM=f6ff8b7a38bab7d8f3cb7b70c7201494a5485c2cf12e84a13c9e232fa51ebfe7 |
| 15 | + |
| 16 | +# fetch, verify the toolchain |
| 17 | +RUN wget https://static.rust-lang.org/dist/${RUST_TRIPLE}.tar.gz && \ |
| 18 | + echo "${SHA256SUM} ${RUST_TRIPLE}.tar.gz" | sha256sum --check --quiet |
| 19 | + |
| 20 | +# install & cleanup tmp files |
| 21 | +RUN tar -xf ${RUST_TRIPLE}.tar.gz -C /tmp/ && \ |
| 22 | + /tmp/${RUST_TRIPLE}/install.sh --prefix=/usr/${RUST_TRIPLE} \ |
| 23 | + --components=rustc,cargo,rust-std-x86_64-unknown-linux-gnu && \ |
| 24 | + rm -rf /tmp/${RUST_TRIPLE} && \ |
| 25 | + rm /${RUST_TRIPLE}* |
| 26 | + |
| 27 | +# This image is based on clang-*jinja2 which only has clang installed, but rustc |
| 28 | +# defaults to linker "cc" which usually points to the GNU/GCC stack. Pointing cc |
| 29 | +# to clang ensures both cargo and kernel build rustc invocations use llvm/clang. |
| 30 | +RUN update-alternatives --install /usr/bin/cc cc $(which clang) 30 && \ |
| 31 | + update-alternatives --set cc $(which clang) |
| 32 | + |
| 33 | +RUN git clone --recurse-submodules --branch $RUST_VER \ |
| 34 | + https://github.com/rust-lang/rust \ |
| 35 | + $(rustc --print sysroot)/lib/rustlib/src/rust |
| 36 | + |
| 37 | +RUN cargo install --locked --version ${BINDGEN_VER} bindgen |
| 38 | + |
| 39 | +# kernel build generates some rust code and tries to format it, if rustfmt is |
| 40 | +# missing it will print non-fatal error noise |
| 41 | +RUN cargo install rustfmt |
| 42 | + |
| 43 | +{%- endblock %} |
0 commit comments