Created
February 8, 2019 14:32
-
-
Save kkayal/e0725864d896d10ceeb34bde10464ede to your computer and use it in GitHub Desktop.
Compile gcc 8.2 on ubuntu 18.04.1 LTS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo apt-get -y update | |
sudo apt-get -y upgrade | |
sudo apt-get -y install binutils gcc g++ wget make lzip texinfo | |
mkdir ~/gcc | |
mkdir ~/gcc-src | |
# Get GCC 8.2 from the official source | |
wget ftp://gcc.gnu.org/pub/gcc/releases/gcc-8.2.0/gcc-8.2.0.tar.xz | |
mv gcc-8.2.0.tar.xz ~/gcc-src | |
# Get the GNU Multiple Precision Library (GMP) version 4.3.2 (or later) from the official source | |
wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.lz | |
mv gmp-6.1.2.tar.lz ~/gcc-src | |
# Get the isl library version 0.15 (or later) from the official source | |
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2 | |
mv isl-0.18.tar.bz2 ~/gcc-src | |
# Get the GNU MPC library version 0.8.1 (or later) from the official source | |
wget https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz | |
mv mpc-1.1.0.tar.gz ~/gcc-src | |
# Get the GNU MPFR library version 2.4.2 (or later) from the official source | |
wget https://www.mpfr.org/mpfr-current/mpfr-4.0.2.tar.gz | |
mv mpfr-4.0.2.tar.gz ~/gcc-src | |
# Unpack them | |
cd ~/gcc-src | |
tar xf gcc-8.2.0.tar.xz | |
tar xf gmp-6.1.2.tar.lz | |
tar xf isl-0.18.tar.bz2 | |
tar xf mpc-1.1.0.tar.gz | |
tar xf mpfr-4.0.2.tar.gz | |
# Move them to the gcc subdirectory | |
mv gmp-6.1.2 gcc-8.2.0/gmp | |
mv isl-0.18 gcc-8.2.0/isl | |
mv mpc-1.1.0 gcc-8.2.0/mpc | |
mv mpfr-4.0.2 gcc-8.2.0/mpfr | |
# Create the build directory | |
mkdir build && cd build | |
# Configure only c, c++ and lto and only 64 bit | |
../gcc-8.2.0/configure --disable-multilib --enable-languages=c,c++,lto | |
# Bootstrapping & building | |
make -j4 BOOT_CFLAGS='-O' bootstrap | |
# Installing | |
make DESTDIR=~/gcc install-strip | |
mv ~/gcc/usr/local/* ~/gcc | |
rm -r ~/gcc/usr | |
# Cleaning up all ubuntu packages except binutils and make | |
# apt -y purge gcc g++ wget lzip texinfo | |
# Deleting all source and build files. Ask the user befor deleting | |
echo "Finished! gcc and g++ are now located at ~~/gcc/bin" | |
echo "Ready to delete the source files and the intermediate files" | |
rm -Ir ~/gcc-src |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment