Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save raghughanapuram/c6ad5406f9ddfe0345bfae2def2defa0 to your computer and use it in GitHub Desktop.
Save raghughanapuram/c6ad5406f9ddfe0345bfae2def2defa0 to your computer and use it in GitHub Desktop.
How to build and install gcc 4.7 for Fedora 22 alongside gcc 5.1
#!/bin/bash
#Install build dependencies
sudo dnf groupinstall "Development tools"
sudo dnf install mpfr-devel gmp-devel libmpc-devel zlib-devel glibc-devel.i686 glibc-devel
wget http://mirror2.babylon.network/gcc/releases/gcc-4.7.4/gcc-4.7.4.tar.bz2
tar xvfj gcc-4.7.4.tar.bz2
cd gcc-4.7.4
#Download and apply fix to be able to build gcc 4.7 with gcc 5.1
wget https://patchwork.ozlabs.org/patch/504982/raw/ -O cfns-fix-mismatch-in-gnu_inline-attributes.patch
patch -p1 -i cfns-fix-mismatch-in-gnu_inline-attributes.patch
mkdir build
cd build
#configure to only build for c,c++,fortran and added suffix otherwise same flages as for gcc 5.1 on Fedora
../configure --enable-bootstrap --enable-languages=c,c++,fortran --prefix=/usr --program-suffix=-4.7 --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --disable-libgcj --with-default-libstdcxx-abi=c++98 --with-isl --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
#Use old ABI as old ABI is still used in Fedora 22?
#http://developerblog.redhat.com/2015/02/05/gcc5-and-the-c11-abi/
#export CFLAGS_FOR_BUILD="-g -O2 -D_GLIBCXX_USE_CXX11_ABI=0 -Wabi-tags"
#build
make
#snapshot filesystem so we can rollback if things go bananas
sudo mkdir /.snapshots
sudo btrfs subvolume snapshot / /.snapshots/snap1
#install
sudo make install
#check the install
gcc -v
#Using built-in specs.
#COLLECT_GCC=gcc
#COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/5.1.1/lto-wrapper
#Target: x86_64-redhat-linux
#Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --disable-libgcj --with-default-libstdcxx-abi=c++98 --with-isl --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
#Thread model: posix
#gcc version 5.1.1 20150618 (Red Hat 5.1.1-4) (GCC)
gcc-4.7 -v
#Using built-in specs.
#COLLECT_GCC=gcc-4.7
#COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.7.4/lto-wrapper
#Target: x86_64-redhat-linux
#Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran --prefix=/usr --program-suffix=-4.7 --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --disable-libgcj --with-default-libstdcxx-abi=c++98 --with-isl --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
#Thread model: posix
#gcc version 4.7.4 (GCC)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment