Skip to content

Commit

Permalink
Add gcc-12 build
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyubo committed May 9, 2022
1 parent 680d6a6 commit 9594df7
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 3 deletions.
34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,50 @@
# GCC Build Docker for Ubuntu

## Build gcc-11/aarch64-gcc-11 for Ubuntu 20.04
## GCC 12

### Build gcc-12/amd64 for Ubuntu 20.04

Run the following command to build gcc-12/amd64:

cd amd64/gcc-12-ubuntu
docker build -t gcc-12.1.0:ubuntu-20.04 .
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

### Install

Now you can install it:

sudo apt install -y /tmp/gcc-12.1.0-1-ubuntu-20.04.deb

Set gcc-12 as high priority:

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 12

For convenience, add `/usr/lib64` to `LD_LIBRARY_PATH` environment:

export LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH
echo "export LD_LIBRARY_PATH=\"/usr/lib64:\$LD_LIBRARY_PATH\"" >> ~/.bashrc

## GCC 11

### Build gcc-11/aarch64-gcc-11 for Ubuntu 20.04

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

cd amd64/gcc-11-ubuntu
docker build -t gcc-11.2:ubuntu-20.04 --build-arg UbuntuVersion=20.04 .
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

## Build gcc-11/aarch64-gcc-11 for Ubuntu 18.04
### Build gcc-11/aarch64-gcc-11 for Ubuntu 18.04

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

cd amd64/gcc-11-ubuntu
docker build -t gcc-11.2:ubuntu-18.04 --build-arg UbuntuVersion=18.04 .
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

## Install
### Install

Now you can install it:

Expand Down
6 changes: 6 additions & 0 deletions amd64/gcc-12-ubuntu/DEBIAN/control.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Package: gcc-12-ubuntu-UBUNTUVERSION
Version: VERSION
Architecture: amd64
Maintainer: xyb <[email protected]>
Description: Gcc VERSION build for ubuntu UBUNTUVERSION
Depends: binutils, libc6-dev
63 changes: 63 additions & 0 deletions amd64/gcc-12-ubuntu/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
ARG UbuntuVersion=20.04

FROM ubuntu:$UbuntuVersion

ARG Gcc12Version=12.1.0

# Download gcc source code
RUN apt update && apt install -y wget build-essential file flex libz-dev libzstd-dev
RUN wget https://gcc.gnu.org/pub/gcc/releases/gcc-$Gcc12Version/gcc-$Gcc12Version.tar.gz
RUN tar xf gcc-$Gcc12Version.tar.gz
RUN cd /gcc-$Gcc12Version && ./contrib/download_prerequisites

# Build x86_64-gcc-12
RUN mkdir /x86_64-gcc-12
WORKDIR /x86_64-gcc-12
RUN /gcc-$Gcc12Version/configure \
--enable-languages=c,c++ \
--prefix=/usr \
--with-gcc-major-version-only \
--program-suffix=-12 \
--enable-shared \
--enable-linker-build-id \
--libexecdir=/usr/lib \
--without-included-gettext \
--enable-threads=posix \
--libdir=/usr/lib \
--disable-nls \
--enable-clocale=gnu \
--enable-libstdcxx-debug \
--enable-libstdcxx-time=yes \
--with-default-libstdcxx-abi=new \
--enable-gnu-unique-object \
--disable-vtable-verify \
--enable-plugin \
--enable-default-pie \
--with-system-zlib \
--enable-libphobos-checking=release \
--with-target-system-zlib=auto \
--disable-werror \
--enable-cet \
--with-abi=m64 \
--disable-multilib \
--with-tune=generic \
--without-cuda-driver \
--enable-checking=release \
--build=x86_64-linux-gnu \
--host=x86_64-linux-gnu \
--target=x86_64-linux-gnu
RUN make -j`nproc`

ARG BuildVersion=1
ARG UbuntuVersion=20.04

RUN make install-strip DESTDIR=/gcc-$Gcc12Version-$BuildVersion-ubuntu-$UbuntuVersion
RUN mkdir -p /gcc-$Gcc12Version-$BuildVersion-ubuntu-$UbuntuVersion/usr/share/gdb/auto-load/usr/lib64 && \
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

# Generate deb
WORKDIR /
COPY DEBIAN/control.m4 /
RUN mkdir /gcc-$Gcc12Version-$BuildVersion-ubuntu-$UbuntuVersion/DEBIAN
RUN m4 -P -DUBUNTUVERSION=$UbuntuVersion -DVERSION=$Gcc12Version-$BuildVersion control.m4 > /gcc-$Gcc12Version-$BuildVersion-ubuntu-$UbuntuVersion/DEBIAN/control
RUN dpkg-deb --build --root-owner-group /gcc-$Gcc12Version-$BuildVersion-ubuntu-$UbuntuVersion

0 comments on commit 9594df7

Please sign in to comment.