Skip to content

Commit 125753e

Browse files
committed
Add gcc 13 image
1 parent f47d3ab commit 125753e

File tree

4 files changed

+198
-0
lines changed

4 files changed

+198
-0
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ jobs:
7373
erlang/26: 'erlang/26/**'
7474
flake8: 'flake8/**'
7575
fpm: 'fpm/**'
76+
gcc/13: 'gcc/13/**'
7677
glab: 'glab/**'
7778
go2chef: 'go2chef/**'
7879
golang/1.24/noble: 'golang/1.24/noble/**'

gcc/13/Containerfile

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

gcc/13/docker-bake.hcl

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
variable "TAG_PREFIX" {
2+
default = "docker.io/boxcutter/gcc"
3+
}
4+
5+
variable "VERSION" {
6+
default = "13.4.0"
7+
}
8+
9+
# There's no darwin-based Docker, so if we're running on macOS, change the platform to linux
10+
variable "LOCAL_PLATFORM" {
11+
default = regex_replace("${BAKE_LOCAL_PLATFORM}", "^(darwin)", "linux")
12+
}
13+
14+
target "_common" {
15+
dockerfile = "Containerfile"
16+
tags = [
17+
"${TAG_PREFIX}:${VERSION}-noble",
18+
"${TAG_PREFIX}:${join(".", slice(split(".", "${VERSION}"), 0, 2))}-noble",
19+
]
20+
labels = {
21+
"org.opencontainers.image.source" = "https://github.com/boxcutter/oci"
22+
"org.opencontainers.image.licenses" = "Apache-2.0"
23+
"org.opencontainers.image.description" = "The GNU Compiler Collection is a compiling system that supports several languages."
24+
"org.opencontainers.image.title" = "${TAG_PREFIX}"
25+
"org.opencontainers.image.created" = "${timestamp()}"
26+
"dev.boxcutter.image.readme-filepath" = "gcc/README.md"
27+
}
28+
}
29+
30+
target "local" {
31+
inherits = ["_common"]
32+
platforms = ["${LOCAL_PLATFORM}"]
33+
}
34+
35+
target "default" {
36+
inherits = ["_common"]
37+
platforms = ["linux/amd64", "linux/arm64/v8"]
38+
}
39+

gcc/13/test/controls/gcc.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
describe command('gcc') do
2+
it { should exist }
3+
end

0 commit comments

Comments
 (0)