Skip to content

Commit c8c6437

Browse files
committed
Revert "REVERT THIS: disable GCC build to speed up workflows"
This reverts commit 055005a.
1 parent 3c20c33 commit c8c6437

File tree

1 file changed

+156
-1
lines changed

1 file changed

+156
-1
lines changed
Lines changed: 156 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,156 @@
1-
FROM gcc:12-bullseye
1+
FROM buildpack-deps:bullseye
2+
3+
## NOTE: EVERYTHING BELOW THIS COMMENT IS FROM
4+
## https://github.com/docker-library/gcc/blob/7070981b23d22d3ca790f87bff26f13f3614dd4c/12/Dockerfile
5+
6+
7+
RUN set -eux; \
8+
apt-get update; \
9+
apt-get install -y --no-install-recommends \
10+
# install abigail-tools so we can use abidiff later to verify that we don't break Debian packages
11+
abigail-tools \
12+
; \
13+
rm -rf /var/lib/apt/lists/*
14+
15+
# https://gcc.gnu.org/mirrors.html
16+
ENV GPG_KEYS \
17+
# 1024D/745C015A 1999-11-09 Gerald Pfeifer <gerald@pfeifer.com>
18+
B215C1633BCA0477615F1B35A5B3A004745C015A \
19+
# 1024D/B75C61B8 2003-04-10 Mark Mitchell <mark@codesourcery.com>
20+
B3C42148A44E6983B3E4CC0793FA9B1AB75C61B8 \
21+
# 1024D/902C9419 2004-12-06 Gabriel Dos Reis <gdr@acm.org>
22+
90AA470469D3965A87A5DCB494D03953902C9419 \
23+
# 1024D/F71EDF1C 2000-02-13 Joseph Samuel Myers <jsm@polyomino.org.uk>
24+
80F98B2E0DAB6C8281BDF541A7C8C3B2F71EDF1C \
25+
# 2048R/FC26A641 2005-09-13 Richard Guenther <richard.guenther@gmail.com>
26+
7F74F97C103468EE5D750B583AB00996FC26A641 \
27+
# 1024D/C3C45C06 2004-04-21 Jakub Jelinek <jakub@redhat.com>
28+
33C235A34C46AA3FFB293709A328C3A2C3C45C06 \
29+
# 4096R/09B5FA62 2020-05-28 Jakub Jelinek <jakub@redhat.com>
30+
D3A93CAD751C2AF4F8C7AD516C35B99309B5FA62
31+
32+
# https://gcc.gnu.org/mirrors.html
33+
ENV GCC_MIRRORS \
34+
https://ftpmirror.gnu.org/gcc \
35+
https://mirrors.kernel.org/gnu/gcc \
36+
https://bigsearcher.com/mirrors/gcc/releases \
37+
http://www.netgull.com/gcc/releases \
38+
https://ftpmirror.gnu.org/gcc \
39+
# "sourceware.org" is the canonical upstream release host (the host of "gcc.gnu.org")
40+
https://sourceware.org/pub/gcc/releases \
41+
# only attempt the origin FTP as a mirror of last resort
42+
ftp://ftp.gnu.org/gnu/gcc
43+
44+
# Last Modified: 2025-07-11
45+
ENV GCC_VERSION 12.5.0
46+
# Docker EOL: 2027-01-11
47+
48+
RUN set -ex; \
49+
\
50+
savedAptMark="$(apt-mark showmanual)"; \
51+
apt-get update; \
52+
apt-get install -y --no-install-recommends \
53+
dpkg-dev \
54+
flex \
55+
gnupg \
56+
; \
57+
rm -r /var/lib/apt/lists/*; \
58+
\
59+
_fetch() { \
60+
local fetch="$1"; shift; \
61+
local file="$1"; shift; \
62+
for mirror in $GCC_MIRRORS; do \
63+
if curl -fL "$mirror/$fetch" -o "$file"; then \
64+
return 0; \
65+
fi; \
66+
done; \
67+
echo >&2 "error: failed to download '$fetch' from several mirrors"; \
68+
return 1; \
69+
}; \
70+
\
71+
_fetch "gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.xz.sig" 'gcc.tar.xz.sig'; \
72+
_fetch "gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.xz" 'gcc.tar.xz'; \
73+
export GNUPGHOME="$(mktemp -d)"; \
74+
for key in $GPG_KEYS; do \
75+
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key"; \
76+
done; \
77+
gpg --batch --verify gcc.tar.xz.sig gcc.tar.xz; \
78+
gpgconf --kill all; \
79+
rm -rf "$GNUPGHOME"; \
80+
mkdir -p /usr/src/gcc; \
81+
tar -xf gcc.tar.xz -C /usr/src/gcc --strip-components=1; \
82+
rm gcc.tar.xz*; \
83+
\
84+
cd /usr/src/gcc; \
85+
\
86+
# "download_prerequisites" pulls down a bunch of tarballs and extracts them,
87+
# but then leaves the tarballs themselves lying around
88+
./contrib/download_prerequisites; \
89+
{ rm *.tar.* || true; }; \
90+
\
91+
# explicitly update autoconf config.guess and config.sub so they support more arches/libcs
92+
for f in config.guess config.sub; do \
93+
wget -O "$f" "https://git.savannah.gnu.org/cgit/config.git/plain/$f?id=7d3d27baf8107b630586c962c057e22149653deb"; \
94+
# find any more (shallow) copies of the file we grabbed and update them too
95+
find -mindepth 2 -name "$f" -exec cp -v "$f" '{}' ';'; \
96+
done; \
97+
\
98+
dir="$(mktemp -d)"; \
99+
cd "$dir"; \
100+
\
101+
extraConfigureArgs=''; \
102+
dpkgArch="$(dpkg --print-architecture)"; \
103+
case "$dpkgArch" in \
104+
# with-arch: https://salsa.debian.org/toolchain-team/gcc/-/blob/gcc-13-debian/debian/rules2#L533-573
105+
# with-float: https://salsa.debian.org/toolchain-team/gcc/-/blob/gcc-13-debian/debian/rules2#L521-523
106+
# with-mode: https://salsa.debian.org/toolchain-team/gcc/-/blob/gcc-13-debian/debian/rules2#L571
107+
armel) \
108+
extraConfigureArgs="$extraConfigureArgs --with-arch=armv5te --with-float=soft" \
109+
;; \
110+
armhf) \
111+
# https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1939379/comments/2
112+
extraConfigureArgs="$extraConfigureArgs --with-arch=armv7-a+fp --with-float=hard --with-mode=thumb" \
113+
;; \
114+
\
115+
# with-arch-32: https://salsa.debian.org/toolchain-team/gcc/-/blob/gcc-13-debian/debian/rules2#L670
116+
i386) \
117+
extraConfigureArgs="$extraConfigureArgs --with-arch-32=i686"; \
118+
;; \
119+
esac; \
120+
\
121+
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
122+
/usr/src/gcc/configure \
123+
--build="$gnuArch" \
124+
--disable-multilib \
125+
--enable-languages=c,c++,fortran,go \
126+
$extraConfigureArgs \
127+
; \
128+
make -j "$(nproc)"; \
129+
make install-strip; \
130+
\
131+
cd ..; \
132+
\
133+
rm -rf "$dir" /usr/src/gcc; \
134+
\
135+
apt-mark auto '.*' > /dev/null; \
136+
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
137+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false
138+
139+
# gcc installs .so files in /usr/local/lib64 (and /usr/local/lib)...
140+
RUN set -ex; \
141+
# this filename needs to sort higher than all the architecture filenames ("aarch64-...", "armeabi...", etc)
142+
{ echo '/usr/local/lib64'; echo '/usr/local/lib'; } > /etc/ld.so.conf.d/000-local-lib.conf; \
143+
ldconfig -v; \
144+
# the libc created by gcc might be too old for a newer Debian
145+
# check that the Debian libstdc++ doesn't have newer requirements than the gcc one
146+
deb="$(readlink -ve /usr/lib/*/libstdc++.so* | head -1)"; \
147+
gcc="$(readlink -ve /usr/local/lib*/libstdc++.so | head -1)"; \
148+
# using LD_PRELOAD to make sure "abidiff" itself doesn't fail with the exact error we're trying to test for 😂😭
149+
LD_PRELOAD="$deb" abidiff --no-added-syms "$deb" "$gcc"
150+
151+
# ensure that alternatives are pointing to the new compiler and that old one is no longer used
152+
RUN set -ex; \
153+
dpkg-divert --divert /usr/bin/gcc.orig --rename /usr/bin/gcc; \
154+
dpkg-divert --divert /usr/bin/g++.orig --rename /usr/bin/g++; \
155+
dpkg-divert --divert /usr/bin/gfortran.orig --rename /usr/bin/gfortran; \
156+
update-alternatives --install /usr/bin/cc cc /usr/local/bin/gcc 999

0 commit comments

Comments
 (0)