Round 8 of gcc-12 attempts (#1301)

Fixes #1271
This commit is contained in:
Alex Kremer
2024-03-28 03:22:03 +00:00
committed by GitHub
parent d2439cc8a9
commit 231556d850
5 changed files with 28 additions and 44 deletions

View File

@@ -1,56 +1,38 @@
FROM ubuntu:focal as build
ARG DEBIAN_FRONTEND=noninteractive
ARG TARGETARCH
SHELL ["/bin/bash", "-c"]
USER root
WORKDIR /root
ENV GCC_VERSION=11 GCC12_VERSION=12.3.0
ENV GCC_VERSION=12.3.0
# Add repositories
RUN apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends --no-install-suggests gnupg wget software-properties-common \
&& add-apt-repository -y ppa:ubuntu-toolchain-r/test \
&& wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - \
&& apt-add-repository 'deb https://apt.kitware.com/ubuntu/ focal main'
# Install gcc-11
RUN apt update -qq \
&& apt install -y --no-install-recommends --no-install-suggests cmake sudo git libmpc-dev libgmp3-dev libmpfr-dev \
make pkg-config libzstd-dev libzstd1 g++-${GCC_VERSION} \
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${GCC_VERSION} 100 \
&& update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-${GCC_VERSION} 100 \
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${GCC_VERSION} 100 \
&& update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-${GCC_VERSION} 100 \
&& update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-${GCC_VERSION} 100 \
&& apt-get clean && apt remove -y software-properties-common
&& apt install -qq -y --no-install-recommends --no-install-suggests \
gnupg wget software-properties-common build-essential
WORKDIR /root/build_gcc
WORKDIR /root
# Install gcc-12 from source
RUN wget "https://mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-${GCC12_VERSION}/gcc-${GCC12_VERSION}.tar.gz" \
&& tar xf "gcc-${GCC12_VERSION}.tar.gz" \
&& cd "gcc-${GCC12_VERSION}" \
RUN wget "https://mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.gz" \
&& tar xf "gcc-${GCC_VERSION}.tar.gz" \
&& cd "gcc-${GCC_VERSION}" \
&& ./contrib/download_prerequisites \
&& mkdir build && cd build \
&& ../configure --enable-languages=c,c++ --disable-multilib --with-build-config='bootstrap-O3' \
&& ../configure --enable-languages=c,c++ --disable-multilib --with-build-config='bootstrap-O3' --prefix='/opt' \
&& make -j$(nproc) profiledbootstrap && make install-strip \
&& rm -rf /root/build_gcc
# Rewire to use gcc-12
RUN update-alternatives --install /usr/bin/g++ g++ /usr/local/bin/g++ 100 \
&& update-alternatives --install /usr/bin/c++ c++ /usr/local/bin/g++ 100 \
&& update-alternatives --install /usr/bin/gcc gcc /usr/local/bin/gcc 100 \
&& update-alternatives --install /usr/bin/cc cc /usr/local/bin/gcc 100
# Clean up
RUN rm -rf /tmp/* /var/tmp/* /root/build_gcc
&& rm -rf /root/*
FROM ubuntu:focal as gcc
WORKDIR /root
# Copy gcc-12 stuff
COPY --from=build /usr/local /usr/local
RUN apt update -qq && apt autoclean -y && apt autoremove -y
COPY --from=build /opt /opt
# Install packages it needs
RUN apt update -qq \
&& apt install -y --no-install-recommends --no-install-suggests libmpc-dev libgmp3-dev libmpfr-dev libzstd-dev libzstd1
# Rewire to use gcc-12
RUN update-alternatives --install /usr/bin/g++ g++ /opt/bin/g++ 100 \
&& update-alternatives --install /usr/bin/c++ c++ /opt/bin/g++ 100 \
&& update-alternatives --install /usr/bin/gcc gcc /opt/bin/gcc 100 \
&& update-alternatives --install /usr/bin/cc cc /opt/bin/gcc 100 \
&& update-alternatives --install /lib/*-linux-gnu/libstdc++.so.6 libstdc++.so.6 /opt/lib64/libstdc++.so.6 100