User Tools

Site Tools


howto:compiling_gcc

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
howto:compiling_gcc [2012/09/04 12:39]
adymond [MPC]
howto:compiling_gcc [2021/12/09 16:42] (current)
Line 1: Line 1:
-====== Compiling GCC 4.6.from Source (STILL UNDER CONSTRUCTION) ======+====== Compiling GCC 4.7.from Source ======
  
-This guide is written as to aid CHPC users who are struggling to compile the GCC version required for their codes. For the official guide on compiling GCC please visit the [[http://gcc.gnu.org/install/|GCC website]]. This guide documents how GCC-4.6.would be built on the Sun Tsessbe Cluster login node, after the August 2012 upgrades.+This guide is written as to aid CHPC users who are struggling to compile the 
 +GCC version required for their codes. For the official guide on compiling GCC 
 +please visit the [[http://gcc.gnu.org/install/|GCC website]]. This guide 
 +documents how GCC 4.7.would be built on the Sun Tsessbe Cluster login node, 
 +after the August 2012 upgrades.
  
-Before you begin, make sure your bash environmental variable are set to their defaults. i.e. All additions to //~/.bashrc// file ([[quick:start#what_you_can_do|example ]])should be commented out. You should see the following from the shell +This guides use the temporary working  /tmp/$USER/gcc_build, the installation 
-  gcc --version +directory of $HOME/local
-    gcc (GCC) 4.3.4+
  
-Also it recommended that a temporary or scratch directory is used to do all the compilation in (i.e. ~/scratch or /tmp/$USER), as to save disk space in your home directory.+Before you begin, comment out all alterations to your //~/.bashrc// file 
 +([[quick:start#what_you_can_do|example ]]). Then log out and in again and you 
 +should seeshould see the following from 
 +the shell 
 +  $ gcc -v 
 +  Using built-in specs. 
 +  Target: x86_64-unknown-linux-gnu 
 +  Configured with: /usr/local/gcc/gcc-4.3.4/configure --prefix=/opt/gridware/gcc-4.3 --disable-multilib 
 +  Thread model: posix 
 +  gcc version 4.1.2 20080704 (Red Hat 4.1.2-52)
  
-Finallynote that for this guideall binary and libraries are installed home directory, i.e prefix=$HOME+Note on the lib folder naming conventionsthe standard in 2012 is to have 
-===== Prerequisites ====+libraries 64 bit by default, and some 32 bit libraries as wellIn Ubuntu 
 +12.04 for example, the following library folder name convention is used 
 +  /usr/lib    /usr/lib32
  
-A table showing what tools and package for building GCC, and what is available on the cluster login node (this is where GCC will be built)+However, on the login node which is little older, its the other way round. The 
 +lib folder refers to 32 bit libraries by default, while the lib64 is for 64 bit 
 +libraries. ie its the chpc nodes have the following naming convention 
 +  /usr/lib64    /usr/lib 
 + 
 +So when you install software, which is 64 bit (default these days) remember you 
 +want to install it in the lib64 and not the lib folder, as the lib64 folders are 
 +searched first. ie use the following compilation flag --libdir=$HOME/local/lib64 
 + 
 +===== Setting up the latest GNU binutils and libtool ===== 
 + 
 +The latest version of of these libraries are going to be setup in the your 
 +local directory 
 + 
 +=== BinUtils === 
 + 
 +BinUtils version 
 +  $ ld --version 
 +  GNU ld version 2.17.50.0.6-20.el5_8.3 20061020 
 +  $ ld --verbose | grep SEARCH 
 +  SEARCH_DIR("/usr/x86_64-redhat-linux/lib64"); SEARCH_DIR("/usr/local/lib64"); SEARCH_DIR("/lib64"); 
 +  SEARCH_DIR("/usr/lib64"); SEARCH_DIR("/usr/x86_64-redhat-linux/lib"); 
 +  SEARCH_DIR("/usr/lib64");  SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib"); 
 + 
 +Install the latest version of GNU bin utils, as follows 
 +  $ mkdir -p /tmp/$USER/gcc_build 
 +  $ cd /tmp/$USER/gcc_build 
 +  $ wget http://ftp.gnu.org/gnu/binutils/binutils-2.22.tar.gz 
 +  $ tar -xf binutils-2.22.tar.gz 
 +  $ mkdir binutils-2.22/BUILD 
 +  $ cd binutils-2.22/BUILD 
 +  $ mkdir $HOME/local 
 +  $ ../configure --prefix=$HOME/local --libdir=$HOME/local/lib64 
 +  $ make # takes a couple of minutes 
 +  $ make check 1> make.check 2>&1 # should take 5 minutes to complete 
 +If all tests are passed: 
 +  $ grep -i -e pass -e fail -e summary make.check 
 +  === binutils Summary === 
 +  # of expected passes 94 
 +  === gas Summary === 
 +  # of expected passes         625 
 +  ===  ld Summary === 
 +  # of expected passes 703 
 +  # of expected failures 61 
 +  ./test-demangle: 844 tests, 0 failures 
 +proceed, 
 +  make install 
 + 
 +Add the following to bashrc file,  
 +  export PATH=$HOME/bin:$PATH 
 +  export PATH=$HOME/local/bin:$PATH 
 +  unset  LD_LIBRARY_PATH  # the default value is non-sensical now.. 
 + 
 +log in and out again, and 
 +  $ ld -v 
 +  GNU ld (GNU Binutils) 2.22 
 +And neatly enough, now your local paths have been added to the ld search pash 
 +  $ ld --verbose | grep SEARCH 
 +  SEARCH_DIR("/export/home/$USER/local/x86_64-unknown-linux-gnu/lib64"); 
 +  SEARCH_DIR("/export/home/$USER/local/lib64"); 
 +  SEARCH_DIR("/usr/local/lib64"); SEARCH_DIR("/lib64"); 
 +  SEARCH_DIR("/usr/lib64"); 
 +  SEARCH_DIR("/export/home/$USER/local/x86_64-unknown-linux-gnu/lib"); 
 +  SEARCH_DIR("/export/home/$USER/local/lib"); SEARCH_DIR("/usr/local/lib"); 
 +  SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib"); 
 +kewl, :) 
 + 
 +SideNote : the LD_LIBRARY_PATH variable does not effect the output of  
 +//ld --verbose | grep SEARCH // 
 + 
 +=== libtool === 
 + 
 +Take moment the reader though the libtool configuration, 
 +  $libtool --config | less 
 +  $libtool --version 
 +  ltmain.sh (GNU libtool) 1.5.22 (1.1220.2.365 2005/12/18 22:14:06) 
 + 
 +Download source 
 +  $ cd /tmp/$USER/gcc_build 
 +  $ wget ftp://ftp.gnu.org/gnu/libtool/libtool-2.4.2.tar.gz 
 +  $ tar -xf libtool-2.4.2.tar.gz 
 +  $ cd libtool-2.4.2 
 +  $ mkdir BUILD 
 +  $ cd BUILD 
 +  $ ../configure --prefix=$HOME/local --libdir=$HOME/local/lib64 
 +  $ make 
 +  $ make check 1> make.check 2>& # takes about 10 minutes, so do inside 
 +  screen and tail output... 
 +  $ make install 
 + 
 +check everything out 
 +  $libtool --version 
 +  libtool (GNU libtool) 2.4.2 
 +  $libtool --config | less 
 + 
 +===== GCC Prerequisites ===== 
 + 
 +A table showing what tools and package for building GCC, and what is available 
 +on the cluster login node (this is where GCC will be built)
  
 ^ ** Prerequisite ** ^ ** Version Required (or later) **               ^ ** Available **  | ^ ** Prerequisite ** ^ ** Version Required (or later) **               ^ ** Available **  |
 | ISO C90 compiler  | GCC binary version 2.95    | gcc 4.3.4  | | ISO C90 compiler  | GCC binary version 2.95    | gcc 4.3.4  |
-| GNAT              | ?                                  | ?                              |+| GNAT              | ?                                  | ? |
 | A “working” POSIX compatible shell, or GNU bash | | bash available | | A “working” POSIX compatible shell, or GNU bash | | bash available |
 | awk                |GNU awk version 3.1.5 | GNU awk version 3.1.5 | | awk                |GNU awk version 3.1.5 | GNU awk version 3.1.5 |
-| GNU binutils | | |+| GNU binutils | | 2.17 |
 | gzip   | 1.2.4 | 1.3.5  | | gzip   | 1.2.4 | 1.3.5  |
 | gzip2  | 1.0.2  | 1.0.3  | | gzip2  | 1.0.2  | 1.0.3  |
Line 25: Line 137:
 | Perl   | 5.6.1 | 5.8.8 | | Perl   | 5.6.1 | 5.8.8 |
 | jar, or InfoZIP | | ? | | jar, or InfoZIP | | ? |
-| GMP Library              | 4.3.2                          ^ 4.1.3                        +| GMP Library         | 4.3.2                          ^ 4.1.3 | 
-| MPFR Library        | 2.4.2                          ^No                             |+| MPFR Library        | 2.4.2                          ^No |
 | MPC Library         | 0.8.1                          ^No | | MPC Library         | 0.8.1                          ^No |
 +| PPL Library         | 0.11.1                         ^No |
 +| ClooG Library       | 0.16.X                         ^No |
  
-So the GMPMPFR and MPC support libraries need to build before install gccAlso note from [[http://gcc.gnu.org/install/prerequisites.html | http://gcc.gnu.org/install/prerequisites.html]] +ClooG noteonline docs and compiler checks differ on this oneOnline docs 
-"While any sufficiently new version of required tools usually worklibrary requirements are generally stricterNewer versions may work in some casesbut it's safer to use the exact versions documented"+say ClooG 0.17 (built using the ISL 0.10) is required, where gcc configure 
 +checks for Cloog 0.16.XBut the conpiler does have an option to ignore Cloog 
 +version, so i really dont knowFor this gcc build guidei used the 0.17.0 
 +ISL version of Cloog.
  
-====  GMP ====+Also note from [[http://gcc.gnu.org/install/prerequisites.html | 
 +http://gcc.gnu.org/install/prerequisites.html]] 
 +"While any sufficiently new version of required tools usually work, library 
 +requirements are generally stricter. Newer versions may work in some cases, 
 +but it's safer to use the exact versions documented"
  
-[[http://gmplib.org/|GMP]] is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating point numbers.+==== gcc-4.2.4 compilers ====
  
-Download the GMP source code +The gcc-4.2.4 c and c++ compilers are going to be used to build the require 
-  $ cd ~/scratch #or cd /tmp/$USER if luster is misbehaving .. +librariesThe gcc-4.2 branch is the last gcc sub version, which does require 
-  $ wget ftp://ftp.gmplib.org/pub/gmp-5.0.5/gmp-5.0.5.tar.bz2 +the GMP, MPFR or MPC libraries.
-  $ tar -xf gmp-5.0.5.tar.bz2 +
  
 +download source
 +  $ cd /tmp/$USER/gcc_build
 +  $ wget http://ftp.gnu.org/gnu/gcc/gcc-4.2.4/gcc-4.2.4.tar.bz2
 +uncompress 
 +  $ tar -xf gcc-4.2.4.tar.bz2
  
-Configure GMP +configure 
-  $ cd gmp-5.0.5 +  $ cd gcc-4.2.4 
-  $ mkdir BUILD_gcc_4.1.2 +  $ mkdir BUILD 
-  $ cd BUILD_gcc_4.1.2 +  $ cd BUILD 
-  $ ../configure --prefix=$HOME +  $ mkdir /tmp/$USER/gcc_build/usr 
-    +  $ ../configure --prefix=/tmp/$USER/gcc_build/usr --libdir=/tmp/$USER/gcc_build/usr/lib64
-Build, if this process is interrupted try run make again  +
-  make +
-   +
-Test it! +
-  $ make check +
-   +
-If all the test are passed (no critical error is thrown for `make check'), install GMP +
-  $  make install+
  
-====  MPFR ====+build inside a screen session 
 +  $ screen 
 +  $ make > make.out 2>&
 +  # crtl-a crtl-d to detach screen 
 +  $ tail -f make.out #to watch compilation progress 
 +  # after the make is complete, close the screen session by $ screen -r, then 
 +  ctrl-d
  
-The [[ http://www.mpfr.org/ | MPFR library ]] is a C library for multiple-precision floating-point computations with correct rounding+This compiliation took just under 2 hours to complete, when this guide was 
 +writtenFuture work, disabling the build of lib java will probabily reduce 
 +the build time to less then an hour
  
-Download the MPFR source code +Before continuing its probabily a good idea to test the gcc build ....
-  $ cd ~/scratch #or cd /tmp/$USER if luster is misbehaving .. +
-  $ wget  wget http://www.mpfr.org/mpfr-current/mpfr-3.1.1.tar.gz +
-  $ tar -xf mpfr-3.1.1.tar.gz+
  
-Configure MPFR +=== testing ===
-  $ cd mpfr-3.1.1 +
-  $ mkdir BUILD_gcc_4.1.2 +
-  $ cd BUILD_gcc_4.1.2 +
-  $ ../configure --with-gmp=$HOME --prefix=$HOME+
  
-** NB ** make sure you see `checking if gmp.h version and libgmp version are the same... (5.0.5/5.0.5) yes'. If you do not, its possible your GMP installation failed.+  $ screen 
 +  $ make -k check > make.check 2>&
 +  # ctrl-a crtl-d 
 +  $ tail -f make.check
  
-Build it, +Tests took about 2 hours to complete.
-  $ make +
-   +
-   +
-   +
-Test, +
-  $ make check +
-   +
-If all the test are passed, install +
-  $  make install+
  
-====  MPC ====+Test results, when writing this guide 
 +  $ grep -e '# of ' -e Summary /tmp/$USER/gcc_build/gcc-4.2.4/BUILD/make.check 
 +      === gcc Summary === 
 +  # of expected passes 42433 
 +  # of expected failures 127 
 +  # of unresolved testcases 1 
 +  # of untested testcases 28 
 +  # of unsupported tests 405 
 +     === g++ Summary === 
 +  # of expected passes         13564 
 +  # of expected failures 67 
 +  # of unsupported tests 106
  
-Gnu [[http://www.multiprecision.org|MPC]] is a C library for the arithmetic of complex numbers with arbitrarily high precision and correct rounding of the result 
  
-Download the MPC source code +Only continue with this guide if all the tests are passed
-  $ cd ~/scratch #or cd /tmp/$USER if luster is misbehaving .. +
-  $ wget http://www.multiprecision.org/mpc/download/mpc-0.8.1.tar.gz +
-  $ tar -xf mpc-0.8.1.tar.gz +
  
-Configure GMP +=== installation of gcc === 
-  $ cd mpc-0.8.1/ + 
-  $ mkdir BUILD +Install the compliled gcc if
-  $ cd BUILD +
-  $ ../configure --with-gmp=$HOME --with-mpfr=$HOME --prefix=$HOME +
-  +
-Build and test +
-  $ make +
-  $ make check +
-   +
-If all the tests are passed+
   $ make install   $ make install
-   
-====   ISL Library version 0.10 ==== 
  
-  $ wget ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.10.tar.bz2+Next the [[ 
 +http://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Environment-Variables.html#Environment-Variables 
 +| environment variables affecting GCC 4.2.4 ]] need to be set. Add the 
 +following lines to your .bashrc script file, 
 +  # temporary gcc 4.2.4 build 
 +  export PATH=/tmp/$USER/gcc_build/usr/bin:$PATH 
 +  export LD_LIBRARY_PATH=/tmp/$USER/gcc_build/usr/lib64:/tmp/$USER/gcc_build/usr/lib 
 +  export C_INCLUDE_PATH=$HOME/local/include 
 +  export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH 
 +//Note//, the $HOME/local/ additions are for the libraries which 
 +going to be built using gcc 4.2.4 for the latest gcc version. 
 + 
 +then logout and in again. You should see the following 
 +  $ gcc -v 
 +    ... 
 +    gcc version 4.2.4 
 + 
 +Also check your include paths, and library paths using 
 +  $ echo | gcc -v -x c -E - 
 +  $ echo | gcc -v -x c++ -E - 
 + 
 +Check, gcc 
 +  $ gcc -Wl,--verbose | less 
 + 
 +==== helper script  ==== 
 + 
 +The libraries required all follow the same build procedure, 
 +  1. download and extract 
 +  2. configure 
 +  3. make 
 +  4. make check, and in some cases 
 +  5. make install 
 + 
 + 
 +So a helper script is used to help automate the process. THe helper script 
 +//download_and_install_from_source.sh//, can be download as follows, 
 +  $ mkdir $HOME/local/bin 
 +  $ cd $HOME/local/bin 
 +  $ wget http://dymond.co.za/download_and_install_from_source.sh 
 +  $ chmod +x download_and_install_from_source.sh 
 + 
 +return to your home folder, and you should see 
 +  $ cd ~/ 
 +  $ download_and_install_from_source.sh 
 +    Usage: download_and_install_from_source.sh  TAR_URL  BUILD_DIR  CONFIGURE_OPTIONS  [INSTALL_DIR] 
 + 
 +This helper script, is used in the rest of the guide. DO NOT USE THIS SCRIPT BLINDLY 
 +WITH OUT READING THE APPS DOCUMENTATION AND CONFIGURATION OPTIONS.  
 + 
 + 
 +==== GMP library ==== 
 + 
 +[[http://gmplib.org/|GMP]] is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating point numbers. 
 + 
 +We could: 
 +  $ cd /tmp/$USER/gcc_build 
 +  $ wget ftp://ftp.gmplib.org/pub/gmp-5.0.5/gmp-5.0.5.tar.bz2 
 +  $ tar -xf gmp-5.0.5.tar.bz2 
 +  $ cd gmp-5.0.5
   $ mkdir BUILD   $ mkdir BUILD
   $ cd BUILD   $ cd BUILD
-  $ ../configure --prefix=$HOME+  $ ../configure --prefix=$HOME/local/gcc_libs --enable-cxx
   $ make   $ make
   $ make check   $ make check
   $ make install   $ make install
-   
-====  CLOOG ==== 
  
-Firstbuild and compile the [[http://directory.fsf.org/wiki/Parma_Polyhedra_Library| Parma Polyhedra Library (PPL) ]] +OR simply use our helper script 
-  $  +  $ download_and_install_from_source.sh ftp://ftp.gmplib.org/pub/gmp-5.0.5/gmp-5.0.5.tar.bz2 \ 
-  $ +   /tmp/$USER/gcc_build "--enable-cxx --libdir=$HOME/local/lib64" $HOME/local 
-  $ + 
-  $+Assert that everyting went okay. When the 
 +//download_and_install_from_source.sh// script finishedit outputs the make 
 +check results. You should see a whole bunch of passes and no 
 +fails. Do this for the following library builds as well. 
 + 
 +Finally copy the libraries to the gcc 4.2.4 of search path folder 
 +  $ cp -v $HOME/local/lib64/libgmp* /tmp/$USER/gcc_build/usr/lib64/ 
 +  
 +=== lib64 and lib === 
 + 
 +gcc and the linker search the 64 bit library folders first then the normal (32 
 +bit folders afterwards (check out $ ld --verbose ). By default the latest 
 +versions of gmp install there 64 bit libraries under the lib folder and the 
 +lib64 folder. Which kind of makes sense; i.e. in the future is there going to 
 +need to be lib256 folder?  
 + 
 +The problem is that on the login node gmp in installed in the /usr/lib64 
 +folder. So this folder is found first using the linker and gcc compared to the 
 +/usr/lib folder for example. That is why the compiled libraries are installed 
 +and copied to the 64 bit folders. 
 + 
 +==== MPFR library ==== 
 + 
 +The [[ http://www.mpfr.org/ | MPFR library ]] is a C library for multiple-precision floating-point computations with correct rounding 
 + 
 +  $ download_and_install_from_source.sh http://www.mpfr.org/mpfr-current/mpfr-3.1.1.tar.gz \  
 +  /tmp/$USER/gcc_build "--libdir=$HOME/local/lib64" $HOME/local 
 +  $ cp -v $HOME/local/lib64/libmpfr* /tmp/$USER/gcc_build/usr/lib64/ 
 + 
 +==== MPC library====  
 + 
 +Gnu [[http://www.multiprecision.org|MPC]] is a C library for the arithmetic of 
 +complex numbers with arbitrarily high precision and correct rounding of the result 
 + 
 +  $ download_and_install_from_source.sh http://www.multiprecision.org/mpc/download/mpc-1.0.tar.gz \ 
 +  /tmp/$USER/gcc_build "--libdir=$HOME/local/lib64" $HOME/local 
 +  $ cp -v $HOME/local/lib64/libmpc* /tmp/$USER/gcc_build/usr/lib64/ 
 + 
 +==== PPL ==== 
 + 
 +[[http://bugseng.com/products/ppl/ | The Parma Polyhedra Library ]] (PPL) provides numerical abstractions especially 
 +targeted at applications in the field of analysis and verification of complex systems. 
 + 
 +This one takes a while, so the use screen is recommened: 
 +  $ screen 
 +  $ download_and_install_from_source.sh \  
 +  http://bugseng.com/external/ppl/download/ftp/releases/0.11.2/ppl-0.11.2.tar.bz2 \ 
 +  /tmp/$USER/gcc_build \ 
 +  "--enable-watchdog --libdir=$HOME/local/lib64"
 +   $HOME/local 
 +detach_screen, and come back in 3 hours. To watch the progress use tail 
 +  $ tail -f /tmp/$USER/gcc_build/ppl-0.11.2/BUILD/make.out #for the building 
 +  $ tail -f /tmp/$USER/gcc_build/ppl-0.11.2/BUILD/make.check # for the testing 
 + 
 +make, takes 15 minutes 
 +make ckeck, takes 3 hours 15 minutes 
 + 
 +copy libraries, to gcc 4.2.4 search path 
 +  $ cp -v $HOME/local/lib64/libp* /tmp/$USER/gcc_build/usr/lib64/  
 + 
 + 
 + 
 +==== CLOOG library ==== 
 + 
 +First ISL needs to be installed, 
 +  $ download_and_install_from_source.sh \ 
 +  ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.10.tar.bz2 \ 
 +  /tmp/$USER/gcc_build "--libdir=$HOME/local/lib64" $HOME/local 
 +  $ cp -v $HOME/local/lib64/libisl* /tmp/$USER/gcc_build/usr/lib64/
  
 [[http://www.cloog.org/|CLooG]] is a free software and library to generate code for scanning Z-polyhedra [[http://www.cloog.org/|CLooG]] is a free software and library to generate code for scanning Z-polyhedra
  
-  $ wget ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-ppl-0.15.10.tar.gz +  $ download_and_install_from_source.sh  \  
-  $ tar -xf cloog-ppl-0.15.10.tar.gz +   http://www.bastoul.net/cloog/pages/download/cloog-0.17.0.tar.gz \ 
-  mkdir BUILD +  /tmp/$USER/gcc_build  "--with-isl=system --libdir=$HOME/local/lib64 --with-bits=gmp"  $HOME/local 
-  cd BUILD +  $ cp -v $HOME/local/lib64/libcl* /tmp/$USER/gcc_build/usr/lib64/
-  $ +
  
-===== Download GCC =====+With the required libraries now available, the main GCC build can begin. 
 + 
 +===== Downloading GCC ===== 
 + 
 +  $ cd /tmp/$USER/gcc_build 
 +  $ wget http://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gcc/gcc-4.7.1/gcc-4.7.1.tar.bz2 
 +  $ tar -xf gcc-4.7.1.tar.bz2
  
-Now that the Prerequisites are ready, GCC can be downloaded (i use an http mirror as the ftp mirrors seem to be blocked?). Download GCC 
-  $ cd ~/scratch #or cd /tmp/$USER 
-  $ wget http://www.mirrorservice.org/sites/ftp.gnu.org/gnu/gcc/gcc-4.6.2/gcc-4.6.2.tar.bz2 
-  $ tar -xf gcc-4.6.2.tar.bz2 
-   
 ===== Configuration ===== ===== Configuration =====
      
-  $ cd gcc-4.6.2/+  $ cd gcc-4.7.1/
   $ mkdir BUILD   $ mkdir BUILD
   $ cd BUILD   $ cd BUILD
-  $ ../configure --with-gmp=$HOME --with-mpfr=$HOME --with-mpc=$HOME --prefix=$HOME+  $ ../configure --prefix=$HOME/local --disable-cloog-version-check \ 
 +   --enable-cloog-backend=isl --libdir=$HOME/local/lib64 \ 
 +   --with-mpc-include=$HOME/local/include    --with-mpc-lib=$HOME/local/lib64 \ 
 +   --with-mpfr-include=$HOME/local/include   --with-mpfr-lib=$HOME/local/lib64 \ 
 +   --with-gmp-include=$HOME/local/include    --with-gmp-lib=$HOME/local/lib64 \ 
 +   --with-ppl-include=$HOME/local/include    --with-ppl-lib=$HOME/local/lib64 \ 
 +   --with-cloog-include=$HOME/local/include  --with-cloog-lib=$HOME/local/lib64 
 +The following languages will be built: c,c++,fortran,java,lto,objc 
 +*** This configuration is not supported in the following subdirectories: 
 +     gnattools target-libada target-libgo 
 +    (Any other directories should still work fine.)
 ===== Compiling GCC ===== ===== Compiling GCC =====
  
 Once the configuration is complete, use Make to build GCC Once the configuration is complete, use Make to build GCC
- 
-  $make 
- 
-The compilation process may be unstable, throwing errors such as  
-  * xgcc: internal compiler error: Killed (program cc1) 
-  * gcj: internal compiler error: Killed (program jc1) 
- 
-In these cases, the make process was interrupted due to compile command being killed (try killall cc1 from another shell, while make is running to replicate this error...). My guess is that, in order to prevent users from running jobs from the login node, a ulimit is set as to kill processes running for a long time. These errors can be overcome by rerunning make. You can either do this manually, or automatically. The automatic approach entails  the following (from inside the build directory): 
  
   $ screen   $ screen
-  $ for i in `seq 1 25` ; do echo MAKE CALL $i ; make ; sleep 30 ; done >> make.out 2>&; echo MAKE CALLS FINISHED >> make.out +  $ make > make.out 2>&
-  # detach screen using ctrl-D+  # detach screen using ctrl-a crtl-d
   $ tail -f make.out   $ tail -f make.out
  
-The benefit about this screen approach beyond saving you grey hairs, is that if ssh connection is lost or you close terminal, the compilation job will keep going. The compilation can take multiple hours... Beware though, the screen session uses your default environmental variables defined in your .bashrc file.+Expect the build to take about 2 hours to complete.
  
 +The benefit about this screen approach beyond saving you grey hairs, is that
 +if ssh connection is lost or you close terminal, the compilation job will keep
 +going. The compilation can take multiple hours... Beware though, the screen
 +session uses your default environmental variables defined in your .bashrc
 +file.
  
 +==== Trouble shooting compilation errors ====
  
-===== Testing GCC build =====+=== refer to config.log errors === 
 +    
 +When make encounters an error and aborts the stating refer to config.log for 
 +further information. The trick is find the folder make was in when it threw 
 +that error. This can be done by inspecting the last command executed before 
 +make halted. the //ls// command with the -lh flag can also be used to find 
 +which folder was modified last. 
  
-Before testing the GCC build[[http://www.gnu.org/s/dejagnu/|dejaGNU]] needs to be installed +Once the folder is foundread through the config.log file to get further 
-  $ cd ~/scratch +information on the error. If nessary, take the config file contents available 
-  $ wget http://download.polytechnic.edu.na/pub/ftp.gnu.org/gnu/dejagnu/dejagnu-1.5.tar.gz +in the configure.log file, and paste them into a temporary file 
-  $ tar -xf dejagnu-1.5.tar.gz +ie. //config_debug.c// and rerurn the broken xonfigure command using that 
-  $ cd dejagnu-1.5/ +fileA big help here is to add the -v flag to the xgcc compiler.
-  $ mkdir BUILD #do not build from src directory! +
-  $ cd BUILD  +
-  $ ../configure --prefix=$HOME +
-  $ make +
-  $ make check # ensure that all test are passed before installation +
-  $ make install+
  
-Then sit back for couple of hours while the testing is done, again i used screen so the test wont be interrupted in the event of a lost connection +===== Testing =====
  
-  $ cd ~/scratch/gcc-4.6.2/BUILD+Test your gcc build before installing it.  
 +  $ cd /tmp/$USER/gcc_build/gcc-4.7.1/BUILD
   $ screen   $ screen
   $ make -k check > make.check 2>&1   $ make -k check > make.check 2>&1
-  # detach screen using Ctrl-D+  # detach screen using ctrl-a ctrl-d
   $ tail -f make.check   $ tail -f make.check
  
-After a couple of hours the tests where complete. Selected summaries from the test results (for the build done for this guide) where as follows+Testing took  3hrs 30 minutes
  
-                === gcc Summary === +After the testing was completed, i had the following results 
-   +  $ grep -e '# of ' -e Summary /tmp/$USER/gcc_build/gcc-4.7.1/BUILD/make.check 
-  # of expected passes            77291 +  === gcc Summary === 
-  # of unexpected failures        19 +  # of expected passes 87683 
-  # of unexpected successes       24 +  # of unexpected failures 37 
-  # of expected failures          229 +  # of unexpected successes 40 
-  # of unsupported tests          2067 +  # of expected failurea 273 
-   +  # of unsupported tests 1262 
-                === g++ Summary === +  === g++ Summary === 
-   +  # of expected passes 48687 
-  # of expected passes            27637 +  # of unexpected failures 8 
-  # of unexpected failures        +  # of expected failures 286 
-  # of unexpected successes       +  # of unsupported tests 558 
-  # of expected failures          167 +  === gfortran Summary === 
-  # of unsupported tests          371 +  # of expected passes 41001 
-   +  # of expected failures 56 
-                === gfortran Summary === +  # of unsupported tests 69 
-   +  === objc Summary === 
-  # of expected passes            38951 +  # of expected passes 2988 
-  # of expected failures          41 +  # of expected failures 6 
-  # of unsupported tests          67+  # of unsupported tests 74 
 +  === libstdc++ Summary === 
 +  # of expected passes 8900 
 +  # of expected failures 43 
 +  # of unsupported tests 145 
 +  === libmudflap Summary === 
 +  # of expected passes 1905 
 +  # of unexpected failures 1 
 +  === libffi Summary === 
 +  # of expected passes 1634 
 +  # of expected failures 10 
 +  # of unsupported tests 55 
 +  === libjava Summary === 
 +  # of expected passes 2574 
 +  === boehm-gc Summary === 
 +  # of expected passes 12 
 +  # of unsupported tests 1 
 +  === libgomp Summary === 
 +  # of expected passes 2998 
 +  === libitm Summary === 
 +  # of expected passes 26 
 +  # of expected failures 3 
 +  # of unsupported tests 1
  
-Which is good enough for my purposes since i installed GCC 4.6.2 for the latest gfortran version which passed all its tests ...+ 
 +If the testing results are acceptable for your intended applications, proceed with the installation.
  
  
 ===== Installation ===== ===== Installation =====
  
-If the test results are satisfactory, install GCC to home directory by running +from inside the gcc 4.7.1 build directory
   $ make install   $ make install
-from the gcc BUILD directory. You will also want to add the following lines to ~/.bashrc file 
-   
-  export LD_LIBRARY_PATH=~/lib:$LD_LIBRARY_PATH 
-  export LD_LIBRARY_PATH=~/lib64:$LD_LIBRARY_PATH 
-  export PATH=~/bin:$PATH 
-  export LDFLAGS="-L$HOME/lib64 -L$HOME/lib" 
-  export CPPFLAGS="-I$HOME/include -L$HOME/lib64 -L$HOME/lib" 
-  export CXXFLAGS=$CPPFLAGS 
-  export F77=gfortran 
-   
-Next time you login, you should see 
  
-  $ gcc --version +Remove all the lines added to your rc file since the start of this guideand 
-  gcc (GCC) 4.6.2 +replace them with
-  Copyright (C) 2011 Free Software FoundationInc. +
-  This is free software; see the source for copying conditions.  There is NO +
-  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.+
  
-have fun!+  export PATH=$HOME/bin:$HOME/local/bin:$PATH 
 +  export LD_LIBRARY_PATH=$HOME/local/lib64 
 + 
 +log in and out again, and  
 +  $ gcc -v 
 +  Target: x86_64-unknown-linux-gnu 
 +  ... 
 +  Thread model: posix 
 +  gcc version 4.7.1 (GCC)  
 + 
 +also check out your default gcc paths for including and libraries 
 +  $ echo | gcc -v -x c -E - 
 +  $ echo | gcc -v -x c++ -E - 
 + 
 +check the ld loads paths as well 
 +  $ ld --verbose | grep SEARCH 
 + 
 +BIG NB, THE LIB64 FOLDERS ARE SEARCHED FIRST. So if you install new libraries which by 
 +default these days are 64 bit and go the lib folder, and the system also has 
 +an installed version in the lib64 folder. The systems old version in a lib64 
 +folder is selected before your newer version. So to be safe, when you install new 
 +software, use the following options 
 +  /--prefix=$HOME/local --libdir=$HOME/local/lib64 
 + 
 +size of install 
 +  $ du -sh $HOME/local 
 +  1.2G 
 + 
 +clean up your build directory 
 +  $ rm -r /tmp/$USER/gcc_build 
 +  
/app/dokuwiki/data/attic/howto/compiling_gcc.1346755179.txt.gz · Last modified: 2021/12/09 16:42 (external edit)