12add0d91Sopenharmony_ciFROM ubuntu:22.04
22add0d91Sopenharmony_ci
32add0d91Sopenharmony_ciRUN apt-get update && apt-get install -y --no-install-recommends \
42add0d91Sopenharmony_ci        gcc libc6-dev qemu-user ca-certificates qemu-system-mipsel curl \
52add0d91Sopenharmony_ci        xz-utils patch
62add0d91Sopenharmony_ci
72add0d91Sopenharmony_ciRUN mkdir /toolchain
82add0d91Sopenharmony_ci
92add0d91Sopenharmony_ci# Linux kernel version: 5.4.154
102add0d91Sopenharmony_ci# See build_dir/target-mipsel_mips32_musl/linux-brcm47xx_generic/linux-5.4.154
112add0d91Sopenharmony_ci# Musl version: 1.1.24
122add0d91Sopenharmony_ci# See staging_dir/toolchain-mipsel_mips32_gcc-8.4.0_musl/info.mk
132add0d91Sopenharmony_ciRUN 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 | \
142add0d91Sopenharmony_ci    tar xJf - -C /toolchain --strip-components=1
152add0d91Sopenharmony_ci
162add0d91Sopenharmony_ci# See https://lkml.org/lkml/2014/3/14/269
172add0d91Sopenharmony_ciCOPY sysinfo_guard.patch /toolchain
182add0d91Sopenharmony_ciRUN patch /toolchain/staging_dir/toolchain-mipsel_mips32_gcc-8.4.0_musl/include/linux/kernel.h </toolchain/sysinfo_guard.patch
192add0d91Sopenharmony_ci
202add0d91Sopenharmony_ciENV PATH=$PATH:/rust/bin:/toolchain/staging_dir/toolchain-mipsel_mips32_gcc-8.4.0_musl/bin \
212add0d91Sopenharmony_ci    STAGING_DIR=/toolchain/staging_dir \
222add0d91Sopenharmony_ci    CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-musl-gcc \
232add0d91Sopenharmony_ci    CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_LINKER=mipsel-openwrt-linux-musl-gcc \
242add0d91Sopenharmony_ci    CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_RUNNER="qemu-mipsel -L /toolchain/staging_dir/toolchain-mipsel_mips32_gcc-8.4.0_musl" \
252add0d91Sopenharmony_ci    RUSTFLAGS="-L /toolchain/staging_dir/toolchain-mipsel_mips32_gcc-8.4.0_musl/lib"
26