This repository has been archived on 2024-08-04. You can view files and clone it, but cannot push or open issues or pull requests.
stagex/gcc/Dockerfile

83 lines
2.5 KiB
Docker
Raw Normal View History

2023-12-10 18:05:50 +00:00
ARG REGISTRY=local
FROM ${REGISTRY}/musl:latest as musl
2023-12-16 23:50:40 +00:00
FROM ${REGISTRY}/binutils:latest as binutils
FROM ${REGISTRY}/bootstrap:latest as bootstrap
2023-11-08 22:39:09 +00:00
2023-12-16 23:50:40 +00:00
FROM bootstrap as base
2023-12-12 17:45:39 +00:00
ENV VERSION 12.2.0
ENV SRC_FILE gcc-$VERSION.tar.xz
ENV SRC_SITE https://mirrors.kernel.org/gnu/gcc/gcc-${VERSION}
ENV SRC_HASH e549cf9cf3594a00e27b6589d4322d70e0720cdd213f39beb4181e06926230ff
ENV DEP_SITE https://gcc.gnu.org/pub/gcc/infrastructure/
ENV GMP_FILE gmp-6.2.1.tar.bz2
ENV GMP_HASH eae9326beb4158c386e39a356818031bd28f3124cf915f8c5b1dc4c7a36b4d7c
ENV MPFR_FILE mpfr-4.1.0.tar.bz2
ENV MPFR_HASH feced2d430dd5a97805fa289fed3fc8ff2b094c02d05287fd6133e7f1f0ec926
ENV MPC_FILE mpc-1.2.1.tar.gz
ENV MPC_HASH 17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459
ENV ISL_FILE isl-0.24.tar.bz2
ENV ISL_HASH fcf78dd9656c10eb8cf9fbd5f59a0b6b01386205fe1934b3b287a0a1898145c0
2023-11-08 22:39:09 +00:00
2023-12-12 17:45:39 +00:00
FROM base as fetch
RUN set -eux; \
wget ${SRC_SITE}/${SRC_FILE}; \
echo "${SRC_HASH} ${SRC_FILE}" | sha256sum -c; \
wget ${DEP_SITE}/${GMP_FILE}; \
echo "${GMP_HASH} ${GMP_FILE}" | sha256sum -c; \
wget ${DEP_SITE}/${MPFR_FILE}; \
echo "${MPFR_HASH} ${MPFR_FILE}" | sha256sum -c; \
wget ${DEP_SITE}/${MPC_FILE}; \
echo "${MPC_HASH} ${MPC_FILE}" | sha256sum -c; \
wget ${DEP_SITE}/${ISL_FILE}; \
echo "${ISL_HASH} ${ISL_FILE}" | sha256sum -c
2023-12-12 17:45:39 +00:00
FROM fetch as build
RUN tar -xf ${SRC_FILE}
WORKDIR gcc-${VERSION}
RUN set -eux; \
mv ../*.tar.* .; \
./contrib/download_prerequisites; \
./configure \
2023-11-18 08:37:31 +00:00
--target=x86_64-linux-musl \
--build=x86_64-linux-musl \
--host=x86_64-linux-musl \
2023-12-12 17:45:39 +00:00
--prefix=/usr \
2023-11-18 08:37:31 +00:00
--mandir=/usr/share/man \
--infodir=/usr/share/info \
2023-11-19 00:44:16 +00:00
--libdir=/usr/lib \
2023-11-18 08:37:31 +00:00
--disable-cet \
--disable-fixed-point \
--disable-libstdcxx-pch \
2023-11-08 22:39:09 +00:00
--disable-multilib \
2023-11-18 08:37:31 +00:00
--disable-nls \
--disable-werror \
--enable-__cxa_atexit \
--enable-default-pie \
--enable-default-ssp \
--enable-languages=c,c++ \
2023-11-18 08:37:31 +00:00
--enable-link-serialization=2 \
--enable-linker-build-id; \
2023-12-16 23:50:40 +00:00
make -j "$(nproc)"
2023-11-08 22:39:09 +00:00
2023-12-16 23:50:40 +00:00
FROM build as install
USER 0:0
RUN set -eux; \
make DESTDIR=/rootfs/ install-strip; \
ln -s gcc /rootfs/usr/bin/cc
COPY --from=musl /lib/* /rootfs/lib/
RUN find /rootfs -exec touch -hcd "@0" "{}" +
FROM busybox as test
2023-12-12 17:45:39 +00:00
COPY --from=binutils . /
COPY --from=musl . /
2023-12-16 23:50:40 +00:00
COPY --from=install /rootfs /
2023-12-12 17:45:39 +00:00
ADD test.c .
RUN set -eux; \
gcc test.c -static -o main; \
./main | grep "Success"
FROM scratch as package
2023-12-16 23:50:40 +00:00
COPY --from=build /rootfs /
2023-11-18 08:37:31 +00:00
ENTRYPOINT ["/usr/bin/gcc"]
2023-11-08 22:39:09 +00:00
CMD ["--version"]