Skip to content

Commit 0671977

Browse files
committed
Add GCC 9.1
1 parent 28213c0 commit 0671977

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ language: bash
22
services: docker
33

44
env:
5+
- VERSION=9
56
- VERSION=8
67
- VERSION=7
78
- VERSION=6

9/Dockerfile

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
FROM buildpack-deps:stretch
2+
3+
RUN set -ex; \
4+
if ! command -v gpg > /dev/null; then \
5+
apt-get update; \
6+
apt-get install -y --no-install-recommends \
7+
gnupg \
8+
dirmngr \
9+
; \
10+
rm -rf /var/lib/apt/lists/*; \
11+
fi
12+
13+
# https://gcc.gnu.org/mirrors.html
14+
ENV GPG_KEYS \
15+
# 1024D/745C015A 1999-11-09 Gerald Pfeifer <gerald@pfeifer.com>
16+
B215C1633BCA0477615F1B35A5B3A004745C015A \
17+
# 1024D/B75C61B8 2003-04-10 Mark Mitchell <mark@codesourcery.com>
18+
B3C42148A44E6983B3E4CC0793FA9B1AB75C61B8 \
19+
# 1024D/902C9419 2004-12-06 Gabriel Dos Reis <gdr@acm.org>
20+
90AA470469D3965A87A5DCB494D03953902C9419 \
21+
# 1024D/F71EDF1C 2000-02-13 Joseph Samuel Myers <jsm@polyomino.org.uk>
22+
80F98B2E0DAB6C8281BDF541A7C8C3B2F71EDF1C \
23+
# 2048R/FC26A641 2005-09-13 Richard Guenther <richard.guenther@gmail.com>
24+
7F74F97C103468EE5D750B583AB00996FC26A641 \
25+
# 1024D/C3C45C06 2004-04-21 Jakub Jelinek <jakub@redhat.com>
26+
33C235A34C46AA3FFB293709A328C3A2C3C45C06
27+
RUN set -ex; \
28+
for key in $GPG_KEYS; do \
29+
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
30+
done
31+
32+
# https://gcc.gnu.org/mirrors.html
33+
ENV GCC_MIRRORS \
34+
https://ftpmirror.gnu.org/gcc \
35+
https://bigsearcher.com/mirrors/gcc/releases \
36+
https://mirrors-usa.go-parts.com/gcc/releases \
37+
https://mirrors.concertpass.com/gcc/releases \
38+
http://www.netgull.com/gcc/releases
39+
40+
# Last Modified: 2019-05-03
41+
ENV GCC_VERSION 9.1.0
42+
# Docker EOL: 2020-11-03
43+
44+
RUN set -ex; \
45+
\
46+
savedAptMark="$(apt-mark showmanual)"; \
47+
apt-get update; \
48+
apt-get install -y --no-install-recommends \
49+
dpkg-dev \
50+
flex \
51+
; \
52+
rm -r /var/lib/apt/lists/*; \
53+
\
54+
_fetch() { \
55+
local fetch="$1"; shift; \
56+
local file="$1"; shift; \
57+
for mirror in $GCC_MIRRORS; do \
58+
if curl -fL "$mirror/$fetch" -o "$file"; then \
59+
return 0; \
60+
fi; \
61+
done; \
62+
echo >&2 "error: failed to download '$fetch' from several mirrors"; \
63+
return 1; \
64+
}; \
65+
\
66+
_fetch "gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.xz.sig" 'gcc.tar.xz.sig' \
67+
# 6.5.0 (https://mirrors.kernel.org/gnu/gcc/6.5.0/), no gcc- prefix
68+
|| _fetch "$GCC_VERSION/gcc-$GCC_VERSION.tar.xz.sig"; \
69+
_fetch "gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.xz" 'gcc.tar.xz' \
70+
|| _fetch "$GCC_VERSION/gcc-$GCC_VERSION.tar.xz" 'gcc.tar.xz'; \
71+
gpg --batch --verify gcc.tar.xz.sig gcc.tar.xz; \
72+
mkdir -p /usr/src/gcc; \
73+
tar -xf gcc.tar.xz -C /usr/src/gcc --strip-components=1; \
74+
rm gcc.tar.xz*; \
75+
\
76+
cd /usr/src/gcc; \
77+
\
78+
# "download_prerequisites" pulls down a bunch of tarballs and extracts them,
79+
# but then leaves the tarballs themselves lying around
80+
./contrib/download_prerequisites; \
81+
{ rm *.tar.* || true; }; \
82+
\
83+
# explicitly update autoconf config.guess and config.sub so they support more arches/libcs
84+
for f in config.guess config.sub; do \
85+
wget -O "$f" "https://git.savannah.gnu.org/cgit/config.git/plain/$f?id=7d3d27baf8107b630586c962c057e22149653deb"; \
86+
# find any more (shallow) copies of the file we grabbed and update them too
87+
find -mindepth 2 -name "$f" -exec cp -v "$f" '{}' ';'; \
88+
done; \
89+
\
90+
dir="$(mktemp -d)"; \
91+
cd "$dir"; \
92+
\
93+
extraConfigureArgs=''; \
94+
dpkgArch="$(dpkg --print-architecture)"; \
95+
case "$dpkgArch" in \
96+
# with-arch: https://anonscm.debian.org/viewvc/gcccvs/branches/sid/gcc-6/debian/rules2?revision=9450&view=markup#l491
97+
# with-float: https://anonscm.debian.org/viewvc/gcccvs/branches/sid/gcc-6/debian/rules.defs?revision=9487&view=markup#l416
98+
# with-mode: https://anonscm.debian.org/viewvc/gcccvs/branches/sid/gcc-6/debian/rules.defs?revision=9487&view=markup#l376
99+
armel) \
100+
extraConfigureArgs="$extraConfigureArgs --with-arch=armv4t --with-float=soft" \
101+
;; \
102+
armhf) \
103+
extraConfigureArgs="$extraConfigureArgs --with-arch=armv7-a --with-float=hard --with-fpu=vfpv3-d16 --with-mode=thumb" \
104+
;; \
105+
\
106+
# with-arch-32: https://anonscm.debian.org/viewvc/gcccvs/branches/sid/gcc-6/debian/rules2?revision=9450&view=markup#l590
107+
i386) \
108+
osVersionID="$(set -e; . /etc/os-release; echo "$VERSION_ID")"; \
109+
case "$osVersionID" in \
110+
8) extraConfigureArgs="$extraConfigureArgs --with-arch-32=i586" ;; \
111+
*) extraConfigureArgs="$extraConfigureArgs --with-arch-32=i686" ;; \
112+
esac; \
113+
# TODO for some reason, libgo + i386 fails on https://github.com/gcc-mirror/gcc/blob/gcc-7_1_0-release/libgo/runtime/proc.c#L154
114+
# "error unknown case for SETCONTEXT_CLOBBERS_TLS"
115+
;; \
116+
esac; \
117+
\
118+
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
119+
/usr/src/gcc/configure \
120+
--build="$gnuArch" \
121+
--disable-multilib \
122+
--enable-languages=c,c++,fortran,go \
123+
$extraConfigureArgs \
124+
; \
125+
make -j "$(nproc)"; \
126+
make install-strip; \
127+
\
128+
cd ..; \
129+
\
130+
rm -rf "$dir" /usr/src/gcc; \
131+
\
132+
apt-mark auto '.*' > /dev/null; \
133+
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
134+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false
135+
136+
# gcc installs .so files in /usr/local/lib64...
137+
RUN set -ex; \
138+
echo '/usr/local/lib64' > /etc/ld.so.conf.d/local-lib64.conf; \
139+
ldconfig -v
140+
141+
# ensure that alternatives are pointing to the new compiler and that old one is no longer used
142+
RUN set -ex; \
143+
dpkg-divert --divert /usr/bin/gcc.orig --rename /usr/bin/gcc; \
144+
dpkg-divert --divert /usr/bin/g++.orig --rename /usr/bin/g++; \
145+
dpkg-divert --divert /usr/bin/gfortran.orig --rename /usr/bin/gfortran; \
146+
update-alternatives --install /usr/bin/cc cc /usr/local/bin/gcc 999

0 commit comments

Comments
 (0)