WebFaction
Community site: login faq
0
1

My compiler is getting a bit rusty around the edges.

I want to install GCC 4.6 for better static and dynamic linking, all of the Graphite Loop optimization options, with the full Scalable Whole-Program Optimizer, including and using the latest Binutils and GNU Multiprecision library, for all default languages (c, c++, fortran, java, objc).

I also want it to compile hands-free on both 32-bit CentOS 5 and 64-bit CentOS 6 servers.

asked 08 Jan '12, 23:26

ryans ♦♦
5.0k83159
accept rate: 43%

Note: An install guide for GCC 4.8 is now available as well.

(05 Sep '13, 04:41) ryans ♦♦

Here you go. You can run these commands individually, or you can paste them into a shell script and run it as

bash buildgcc.sh | tee buildgcc.log

Either way, make sure you run it in a screen session.

#!/usr/bin/env bash
#
# Installs GCC. Run this in a screen session.
#

mkdir -p $HOME/bin $HOME/gcc/src $HOME/gcc/bin $HOME/gcc/lib

ln -s $HOME/gcc/lib $HOME/gcc/lib64  # only needed if we're on a 64-bit server.
  # we don't want to maintain two directories, and we're not using multilib.

set +h    # disable shell hashing so we can use binutils right away

# These are useful when running as a full script, to crash on any nonzero exit status
# However, in general, they should not be necessary for this guide.
# set -o errexit
# set -o nounset

# The dependencies are executed during gcc compilation; set run-time paths too
export PATH="$HOME/gcc/bin:$PATH"                       
export LD_LIBRARY_PATH="$HOME/gcc/lib:$LD_LIBRARY_PATH"

############################################################
# GNU Binutils
############################################################
cd $HOME/gcc/src
wget 'http://mirror.ryansanden.com/gcc-4.6/binutils-2.22.tar.bz2'
tar -xjf binutils-2.22.tar.bz2
mkdir binutils-2.22-build
cd binutils-2.22-build
../binutils-2.22/configure --prefix=$HOME/gcc --disable-werror
make          # 4 min
make check
make install

############################################################
# GNU MP Bignum Library 5.0.2
############################################################
cd $HOME/gcc/src
wget 'http://mirror.ryansanden.com/gcc-4.6/gmp-5.0.2.tar.bz2'
tar -xjf gmp-5.0.2.tar.bz2
cd gmp-5.0.2
CPPFLAGS=-fexceptions ./configure --prefix=$HOME/gcc --enable-cxx
make          # 2 min
make check    # 2 min
make install

############################################################
# GNU MFPR Library 5.0.2
############################################################
cd $HOME/gcc/src
wget 'http://mirror.ryansanden.com/gcc-4.6/mpfr-3.1.0.tar.bz2'
wget 'http://mirror.ryansanden.com/gcc-4.6/mpfr-3.1.0-allpatches.patch'
tar -xjf mpfr-3.1.0.tar.bz2
cd mpfr-3.1.0
patch -N -Z -p1 < ../mpfr-3.1.0-allpatches.patch
./configure --prefix=$HOME/gcc --with-gmp=$HOME/gcc
make          # 1.5 min
make check    # 2 min
make install

############################################################
# MPC Library 0.9
############################################################
cd $HOME/gcc/src
wget 'http://mirror.ryansanden.com/gcc-4.6/mpc-0.9.tar.gz'
tar -xzf mpc-0.9.tar.gz
cd mpc-0.9
./configure --prefix=$HOME/gcc --with-gmp=$HOME/gcc --with-mpfr=$HOME/gcc
make          # 0.5 min
make check    # 1.5 min
make install

############################################################
# Parma Polyhedra (PPL) Library 0.11.2
############################################################
cd $HOME/gcc/src
wget 'http://mirror.ryansanden.com/gcc-4.6/ppl-0.11.2.tar.bz2'
tar -xjf ppl-0.11.2.tar.bz2
cd ppl-0.11.2
./configure --prefix=$HOME/gcc --with-gmp-prefix=$HOME/gcc
make          # 20 min
 #make check  # I killed it after 1hr 45min...
make install

############################################################
# CLooG-PPL Library 0.15.11
############################################################
cd $HOME/gcc/src
wget 'http://mirror.ryansanden.com/gcc-4.6/cloog-ppl-0.15.11.tar.gz'
tar -xzf cloog-ppl-0.15.11.tar.gz
cd cloog-ppl-0.15.11
./configure --prefix=$HOME/gcc --with-ppl=$HOME/gcc --with-gmp=$HOME/gcc --with-bits=gmp
make          # 20 sec
make check
make install

############################################################
# GCC 4.6.2
############################################################
cd $HOME/gcc/src
wget 'http://mirror.ryansanden.com/gcc-4.6/gcc-4.6.2.tar.bz2'
tar -xjf gcc-4.6.2.tar.bz2
mkdir gcc-4.6.2-build
cd gcc-4.6.2-build

# Configure it.  See http://gcc.gnu.org/install/configure.html
../gcc-4.6.2/configure --prefix=$HOME/gcc --with-local-prefix=$HOME/gcc \
    --with-gmp=$HOME/gcc --with-mpfr=$HOME/gcc --with-mpc=$HOME/gcc \
    --with-ppl=$HOME/gcc --with-cloog=$HOME/gcc \
    --with-system-zlib --with-gnu-as --with-gnu-ld \
    --enable-clocale=gnu --enable-shared --enable-threads=posix \
    --enable-__cxa_atexit --disable-nls --disable-multilib \

make          # 2 hours
make install

############################################################
# Clean up & set Environment
############################################################
set -h
rm -r $HOME/gcc/src
cd $HOME/gcc/bin && ln -s gcc cc

echo 'export PATH="$HOME/gcc/bin:$PATH"' >> $HOME/.bashrc
echo 'export CPPFLAGS="-I$HOME/gcc/include $CPPFLAGS"' >> $HOME/.bashrc
echo 'export LDFLAGS="-L$HOME/gcc/lib $LDFLAGS"' >> $HOME/.bashrc
echo 'export LD_LIBRARY_PATH="$HOME/gcc/lib:$LD_LIBRARY_PATH"' >> $HOME/.bashrc

Enjoy!

permanent link
This answer is marked "community wiki".

answered 08 Jan '12, 23:33

ryans ♦♦
5.0k83159
accept rate: 43%

edited 05 Sep '13, 04:51

I try do it but, i have this errors:

bash buildgcc.sh | tee buildgcc.log
mkdir: opción inválida -- s
Pruebe `mkdir --help' para más información.
buildgcc.sh: línea 15: ../binutils-2.22/configure: No existe el fichero o el directorio
buildgcc.sh: línea 20: --prefix=/home/salahaddinal/gcc: No existe el fichero o el directorio
buildgcc.sh: línea 25: ../mpfr-3.1.0-allpatches.patch: No existe el fichero o el directorio
make: *** No hay ninguna regla para construir el objetivo `install'.  Alto.
buildgcc.sh: línea 31: --with-mpfr=/home/salahaddinal/gcc: No existe el fichero o el directorio
buildgcc.sh: línea 36: --with-gmp-prefix=/home/salahaddinal/gcc: No existe el fichero o el directorio
make: *** No hay ninguna regla para construir el objetivo `install'.  Alto.
buildgcc.sh: línea 43: --prefix=/home/salahaddinal/gcc: No existe el fichero o el directorio
buildgcc.sh: línea 49: ../gcc-4.6.2/configure: No existe el fichero o el directorio
ln: target «export LDFLAGS="-L$HOME/gcc/lib $LDFLAGS"» is not a directory

But, all folder exists because i try install gccc 4.8 manually each lib, al, and i have other problems.

(19 Jan '15, 02:10) Yusuf Salah ...

@Yusuf Salah AdDin - I had a look at your buildgcc.sh script, and you've got a lot of problems like lines joined that should be separate lines, and single lines that are split into two lines.

Try copying the script again, and make sure it matches what's in the post above. Or, you can download the script from here: buildgcc.sh

(19 Jan '15, 17:44) seanf

Ok, your script works for me, but, i don't know why it finished in a few minutes, is a problem?

Don't works finally, now i have the same fucking problem. I need install this!

make[4]: se sale del directorio `/home/salahaddinal/gcc/src/binutils-2.22-build$ make[3]: se sale del directorio `/home/salahaddinal/gcc/src/binutils-2.22-build$ make[2]: se sale del directorio `/home/salahaddinal/gcc/src/binutils-2.22-build

(31 Jan '15, 03:17) Yusuf Salah ...

That's definitely a problem - this takes hours to build, not a few minutes. Your buildgcc.log log file shows that execution simply ended while building Parma Polyhedra (PPL).

What happened is that your account already has some natural RAM usage and building GCC took you over the limit, so your processes were terminated. You will need to clear out ~/gcc and try again - and we can give you a temporary RAM boost to help with compilation.

(31 Jan '15, 04:19) ryans ♦♦

Thank you very much for your help, now is finish this work :D, Tahnk you for all. @seanf, your script is the only that work's for me, and thank you webfaction for your "Boost" for one day, i could install gcc with this. Thank you.

(01 Feb '15, 06:55) Yusuf Salah ...
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×15

question asked: 08 Jan '12, 23:26

question was seen: 5,000 times

last updated: 01 Feb '15, 06:55

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM