Skip to content

Commit 9594df7

Browse files
committed
Add gcc-12 build
1 parent 680d6a6 commit 9594df7

File tree

3 files changed

+100
-3
lines changed

3 files changed

+100
-3
lines changed

README.md

+31-3
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,50 @@
11
# GCC Build Docker for Ubuntu
22

3-
## Build gcc-11/aarch64-gcc-11 for Ubuntu 20.04
3+
## GCC 12
4+
5+
### Build gcc-12/amd64 for Ubuntu 20.04
6+
7+
Run the following command to build gcc-12/amd64:
8+
9+
cd amd64/gcc-12-ubuntu
10+
docker build -t gcc-12.1.0:ubuntu-20.04 .
11+
docker run --rm --entrypoint cat gcc-12.1.0:ubuntu-20.04 /gcc-12.1.0-1-ubuntu-20.04.deb > /tmp/gcc-12.1.0-1-ubuntu-20.04.deb
12+
13+
### Install
14+
15+
Now you can install it:
16+
17+
sudo apt install -y /tmp/gcc-12.1.0-1-ubuntu-20.04.deb
18+
19+
Set gcc-12 as high priority:
20+
21+
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
22+
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 12
23+
24+
For convenience, add `/usr/lib64` to `LD_LIBRARY_PATH` environment:
25+
26+
export LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH
27+
echo "export LD_LIBRARY_PATH=\"/usr/lib64:\$LD_LIBRARY_PATH\"" >> ~/.bashrc
28+
29+
## GCC 11
30+
31+
### Build gcc-11/aarch64-gcc-11 for Ubuntu 20.04
432

533
Run the following command to build gcc-11/aarch64-gcc-11:
634

735
cd amd64/gcc-11-ubuntu
836
docker build -t gcc-11.2:ubuntu-20.04 --build-arg UbuntuVersion=20.04 .
937
docker run --rm --entrypoint cat gcc-11.2:ubuntu-20.04 /gcc-11.2.0-1-ubuntu-20.04.deb > /tmp/gcc-11.2.0-1-ubuntu-20.04.deb
1038

11-
## Build gcc-11/aarch64-gcc-11 for Ubuntu 18.04
39+
### Build gcc-11/aarch64-gcc-11 for Ubuntu 18.04
1240

1341
Run the following command to build gcc-11/aarch64-gcc-11:
1442

1543
cd amd64/gcc-11-ubuntu
1644
docker build -t gcc-11.2:ubuntu-18.04 --build-arg UbuntuVersion=18.04 .
1745
docker run --rm --entrypoint cat gcc-11.2:ubuntu-18.04 /gcc-11.2.0-1-ubuntu-18.04.deb > /tmp/gcc-11.2.0-1-ubuntu-18.04.deb
1846

19-
## Install
47+
### Install
2048

2149
Now you can install it:
2250

amd64/gcc-12-ubuntu/DEBIAN/control.m4

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Package: gcc-12-ubuntu-UBUNTUVERSION
2+
Version: VERSION
3+
Architecture: amd64
4+
Maintainer: xyb <[email protected]>
5+
Description: Gcc VERSION build for ubuntu UBUNTUVERSION
6+
Depends: binutils, libc6-dev

amd64/gcc-12-ubuntu/Dockerfile

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
ARG UbuntuVersion=20.04
2+
3+
FROM ubuntu:$UbuntuVersion
4+
5+
ARG Gcc12Version=12.1.0
6+
7+
# Download gcc source code
8+
RUN apt update && apt install -y wget build-essential file flex libz-dev libzstd-dev
9+
RUN wget https://gcc.gnu.org/pub/gcc/releases/gcc-$Gcc12Version/gcc-$Gcc12Version.tar.gz
10+
RUN tar xf gcc-$Gcc12Version.tar.gz
11+
RUN cd /gcc-$Gcc12Version && ./contrib/download_prerequisites
12+
13+
# Build x86_64-gcc-12
14+
RUN mkdir /x86_64-gcc-12
15+
WORKDIR /x86_64-gcc-12
16+
RUN /gcc-$Gcc12Version/configure \
17+
--enable-languages=c,c++ \
18+
--prefix=/usr \
19+
--with-gcc-major-version-only \
20+
--program-suffix=-12 \
21+
--enable-shared \
22+
--enable-linker-build-id \
23+
--libexecdir=/usr/lib \
24+
--without-included-gettext \
25+
--enable-threads=posix \
26+
--libdir=/usr/lib \
27+
--disable-nls \
28+
--enable-clocale=gnu \
29+
--enable-libstdcxx-debug \
30+
--enable-libstdcxx-time=yes \
31+
--with-default-libstdcxx-abi=new \
32+
--enable-gnu-unique-object \
33+
--disable-vtable-verify \
34+
--enable-plugin \
35+
--enable-default-pie \
36+
--with-system-zlib \
37+
--enable-libphobos-checking=release \
38+
--with-target-system-zlib=auto \
39+
--disable-werror \
40+
--enable-cet \
41+
--with-abi=m64 \
42+
--disable-multilib \
43+
--with-tune=generic \
44+
--without-cuda-driver \
45+
--enable-checking=release \
46+
--build=x86_64-linux-gnu \
47+
--host=x86_64-linux-gnu \
48+
--target=x86_64-linux-gnu
49+
RUN make -j`nproc`
50+
51+
ARG BuildVersion=1
52+
ARG UbuntuVersion=20.04
53+
54+
RUN make install-strip DESTDIR=/gcc-$Gcc12Version-$BuildVersion-ubuntu-$UbuntuVersion
55+
RUN mkdir -p /gcc-$Gcc12Version-$BuildVersion-ubuntu-$UbuntuVersion/usr/share/gdb/auto-load/usr/lib64 && \
56+
mv /gcc-$Gcc12Version-$BuildVersion-ubuntu-$UbuntuVersion/usr/lib64/libstdc++.so.6.0.30-gdb.py /gcc-$Gcc12Version-$BuildVersion-ubuntu-$UbuntuVersion/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.30-gdb.py
57+
58+
# Generate deb
59+
WORKDIR /
60+
COPY DEBIAN/control.m4 /
61+
RUN mkdir /gcc-$Gcc12Version-$BuildVersion-ubuntu-$UbuntuVersion/DEBIAN
62+
RUN m4 -P -DUBUNTUVERSION=$UbuntuVersion -DVERSION=$Gcc12Version-$BuildVersion control.m4 > /gcc-$Gcc12Version-$BuildVersion-ubuntu-$UbuntuVersion/DEBIAN/control
63+
RUN dpkg-deb --build --root-owner-group /gcc-$Gcc12Version-$BuildVersion-ubuntu-$UbuntuVersion

0 commit comments

Comments
 (0)