1FROM ubuntu:22.04 2 3RUN apt-get update && apt-get install -y --no-install-recommends \ 4 gcc libc6-dev qemu-user ca-certificates qemu-system-mipsel curl \ 5 xz-utils patch 6 7RUN mkdir /toolchain 8 9# Linux kernel version: 5.4.154 10# See build_dir/target-mipsel_mips32_musl/linux-brcm47xx_generic/linux-5.4.154 11# Musl version: 1.1.24 12# See staging_dir/toolchain-mipsel_mips32_gcc-8.4.0_musl/info.mk 13RUN curl --retry 5 -L https://downloads.openwrt.org/releases/21.02.1/targets/bcm47xx/generic/openwrt-sdk-21.02.1-bcm47xx-generic_gcc-8.4.0_musl.Linux-x86_64.tar.xz | \ 14 tar xJf - -C /toolchain --strip-components=1 15 16# See https://lkml.org/lkml/2014/3/14/269 17COPY sysinfo_guard.patch /toolchain 18RUN patch /toolchain/staging_dir/toolchain-mipsel_mips32_gcc-8.4.0_musl/include/linux/kernel.h </toolchain/sysinfo_guard.patch 19 20ENV PATH=$PATH:/rust/bin:/toolchain/staging_dir/toolchain-mipsel_mips32_gcc-8.4.0_musl/bin \ 21 STAGING_DIR=/toolchain/staging_dir \ 22 CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-musl-gcc \ 23 CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_LINKER=mipsel-openwrt-linux-musl-gcc \ 24 CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_RUNNER="qemu-mipsel -L /toolchain/staging_dir/toolchain-mipsel_mips32_gcc-8.4.0_musl" \ 25 RUSTFLAGS="-L /toolchain/staging_dir/toolchain-mipsel_mips32_gcc-8.4.0_musl/lib" 26