Source
FROM scratch AS build
ARG VERSION
COPY --from=stagex/core-busybox . /
COPY --from=stagex/core-binutils . /
COPY --from=stagex/core-bash . /
COPY --from=stagex/core-make . /
COPY --from=stagex/core-cmake . /
COPY --from=stagex/core-python . /
COPY --from=stagex/core-py-setuptools . /
COPY --from=stagex/core-zlib . /
COPY --from=stagex/core-pkgconf . /
COPY --from=stagex/core-openssl . /
COPY --from=stagex/core-perl . /
COPY --from=stagex/core-gcc . /
COPY --from=stagex/core-musl . /
COPY --from=stagex/core-rust . /
COPY --from=stagex/core-curl . /
COPY --from=stagex/core-ca-certificates . /
COPY --from=stagex/core-llvm . /
COPY --from=stagex/core-libzstd . /
COPY --from=stagex/core-libunwind . /
COPY --from=stagex/core-libunwind /usr/lib/. /opt/cross/x86_64-linux-gnu/lib/
COPY --from=stagex/core-cross-x86_64-gnu-gcc . /
ADD fetch/rustc-${VERSION}-src.tar.gz .
WORKDIR rustc-${VERSION}-src
ADD *.patch .
RUN <<EOF
set -eux
PREFIX=/rust-${VERSION}/usr
ARCH=$(uname -m)
./configure \
--build="${ARCH}-unknown-linux-musl" \
--host="${ARCH}-unknown-linux-musl" \
--target="${ARCH}-unknown-linux-gnu" \
--prefix="/usr" \
--llvm-root="/usr" \
--llvm-libunwind="system" \
--sysconfdir="/rootfs/etc" \
--libdir="/opt/cross/lib/${ARCH}-linux-gnu" \
--enable-local-rust \
--enable-clang \
--enable-lld \
--disable-docs \
--enable-llvm-link-shared \
--enable-option-checking \
--enable-locked-deps \
--enable-vendor \
--dist-compression-formats=gz \
--release-channel="stable" \
--set="install.prefix=/rootfs"
python3 x.py build --stage 0 --target ${ARCH}-unknown-linux-gnu library
mkdir -p /rootfs/usr/lib/rustlib/
cp -r \
/rustc-${VERSION}-src/build/${ARCH}-unknown-linux-musl/stage0-sysroot/lib/rustlib/${ARCH}-unknown-linux-gnu \
/rootfs/usr/lib/rustlib/
EOF
FROM stagex/core-filesystem AS package
COPY --from=build /rootfs/ /