This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
guide:compiling_gcc [2011/11/28 09:29] hamish [Testing GCC build] |
guide:compiling_gcc [2021/12/09 16:42] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Compiling GCC from Source ====== | + | Page moved to [[howto:compiling_gcc|Compiling |
| - | + | ||
| - | This guide is written as to try and help 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:// | + | |
| - | + | ||
| - | Before you begin, make sure your bash environmental variable are set correctly, for [[quick: | + | |
| - | + | ||
| - | Also note that for this guide, all binary and libraries are installed home directory, i.e prefix=$HOME. My setup | + | |
| - | $ export PATH=/ | + | |
| - | $ export LD_LIBRARY_PATH=/ | + | |
| - | $ export LD_LIBRARY_PATH=/ | + | |
| - | $ gcc --version | + | |
| - | gcc (GCC) 4.3.4 | + | |
| - | + | ||
| - | + | ||
| - | ===== 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 ** | | + | |
| - | | ISO C90 compiler | + | |
| - | | GNAT | ? | ? | | + | |
| - | | A “working” POSIX compatible shell, or GNU bash | | bash available | | + | |
| - | | awk |GNU awk version 3.1.5 | GNU awk version 3.1.5 | | + | |
| - | | GNU binutils | | ? | | + | |
| - | | gzip | 1.2.4 | 1.3.5 | | + | |
| - | | gzip2 | 1.0.2 | 1.0.3 | | + | |
| - | | GNU tar | 1.14 | 1.15.1 | | + | |
| - | | Perl | 5.6.1 | 5.8.8 | | + | |
| - | | jar, or InfoZIP | | ? | | + | |
| - | | GMP Library | + | |
| - | | MPFR Library | + | |
| - | | MPC Library | + | |
| - | + | ||
| - | So the GMP, MPFR and MPC support libraries need to build before install gcc. Also note from [[http:// | + | |
| - | "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" | + | |
| - | + | ||
| - | ==== GMP ==== | + | |
| - | + | ||
| - | Download the GMP source | + | |
| - | $ cd ~/scratch #or cd /tmp/$USER if luster is misbehaving .. | + | |
| - | $ wget http:// | + | |
| - | $ tar -xf gmp-4.2.4.tar.bz2 | + | |
| - | + | ||
| - | Configure GMP | + | |
| - | $ cd gmp-4.2.4 | + | |
| - | $ mkdir BUILD | + | |
| - | $ cd BUILD | + | |
| - | $ ../ | + | |
| - | + | ||
| - | 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' | + | |
| - | $ make install | + | |
| - | + | ||
| - | ==== MPFR ==== | + | |
| - | + | ||
| - | + | ||
| - | Download the MPFR source code | + | |
| - | $ cd ~/scratch #or cd /tmp/$USER if luster is misbehaving .. | + | |
| - | $ wget http:// | + | |
| - | $ tar -xf mpfr-2.4.2.tar.gz | + | |
| - | + | ||
| - | Configure MPFR | + | |
| - | $ cd mpfr-2.4.2 | + | |
| - | $ mkdir BUILD | + | |
| - | $ cd BUILD | + | |
| - | $ ../ | + | |
| - | + | ||
| - | ** NB ** make sure you see `checking if gmp.h version and libgmp version are the same... (4.2.4/ | + | |
| - | + | ||
| - | Build it, | + | |
| - | $ make | + | |
| - | + | ||
| - | Test, | + | |
| - | $ make check | + | |
| - | + | ||
| - | If all the test are passed, install | + | |
| - | $ make install | + | |
| - | + | ||
| - | ==== MPC ==== | + | |
| - | + | ||
| - | + | ||
| - | Download the MPC source code | + | |
| - | $ cd ~/scratch #or cd /tmp/$USER if luster is misbehaving .. | + | |
| - | $ wget http:// | + | |
| - | $ tar -xf mpc-0.8.1.tar.gz | + | |
| - | + | ||
| - | Configure GMP | + | |
| - | $ cd mpc-0.8.1/ | + | |
| - | $ mkdir BUILD | + | |
| - | $ cd BUILD | + | |
| - | $ ../ | + | |
| - | + | ||
| - | Build and test | + | |
| - | $ make | + | |
| - | $ make check | + | |
| - | + | ||
| - | If all the tests are passed | + | |
| - | $ make install | + | |
| - | + | ||
| - | ===== Download GCC ===== | + | |
| - | + | ||
| - | 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 / | + | |
| - | $ wget http:// | + | |
| - | $ tar -xf gcc-4.6.2.tar.bz2 | + | |
| - | + | ||
| - | ===== Configuration ===== | + | |
| - | + | ||
| - | $ cd gcc-4.6.2/ | + | |
| - | $ mkdir BUILD | + | |
| - | $ cd BUILD | + | |
| - | $ ../ | + | |
| - | ===== Compiling GCC ===== | + | |
| - | + | ||
| - | Once the configuration is complete, use Make to build GCC | + | |
| - | + | ||
| - | $make | + | |
| - | ==== Trouble Shooting ==== | + | |
| - | + | ||
| - | The compilation process may be unstable, requiring make to be run multiple times. If you experience such errors try inside the build directory | + | |
| - | + | ||
| - | $ screen | + | |
| - | $ for i in `seq 1 25` ; do echo MAKE CALL $i ; make ; sleep 6 ; done >> make.out 2>&1 ; echo MAKE CALLS FINISHED >> make.out | + | |
| - | # detach screen using ctrl-D | + | |
| - | $ tail -f make.out | + | |
| - | + | ||
| - | The benefit about this screen approach is that if ssh connection is lost or you close terminal, the job will keep going. | + | |
| - | + | ||
| - | === xgcc: internal compiler error: Killed (program cc1) === | + | |
| - | + | ||
| - | This error occurs when the cc1 process is killed/ | + | |
| - | + | ||
| - | This is a rather annoying error, but just keep running make until all the file are compiled. | + | |
| - | + | ||
| - | === gcj: internal compiler error: Killed (program jc1) === | + | |
| - | + | ||
| - | Again just as with xgcc error, the gcj program was killed/ | + | |
| - | + | ||
| - | ===== Testing GCC build ===== | + | |
| - | + | ||
| - | Before testing the GCC build, [[www.gnu.org/ | + | |
| - | $ cd ~/scratch | + | |
| - | $ wget http:// | + | |
| - | $ tar -xf dejagnu-1.5.tar.gz | + | |
| - | $ cd dejagnu-1.5/ | + | |
| - | $ mkdir BUILD #do not build from src directory! | + | |
| - | $ cd BUILD | + | |
| - | $ ../ | + | |
| - | $ 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 | + | |
| - | + | ||
| - | $ cd ~/ | + | |
| - | $ screen | + | |
| - | $ make -k check > make.check 2>& | + | |
| - | # detach screen using Ctrl-D | + | |
| - | $ tail -f make.check | + | |
| - | + | ||
| - | My test results where as follows | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | ===== Testing GCC build ===== | + | |
| - | + | ||
| - | If the test results are satisfactory, | + | |
| - | $ make install | + | |
| - | from the gcc BUILD directory. You will also want to add the following lines to ~/.bashrc file | + | |
| - | + | ||
| - | export LD_LIBRARY_PATH=~/ | + | |
| - | export LD_LIBRARY_PATH=~/ | + | |
| - | export PATH=~/ | + | |
| - | + | ||
| - | Next time you login, you should see | + | |
| - | + | ||
| - | $ gcc --version | + | |
| - | gcc (GCC) 4.6.2 | + | |
| - | Copyright (C) 2011 Free Software Foundation, Inc. | + | |
| - | This is free software; see the source for copying conditions. | + | |
| - | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | + | |
| - | + | ||
| - | have fun! | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||