Upgrade Redhat 5.5 GCC to 4.7.1 to compile AVX code

Source: Internet
Author: User
Tags gmp

Upgrade Redhat 5.5 GCC to 4.7.1 to compile AVX code

The GCC compiler of Redhat is version 4.1, which does not support SSE4, AVX, and AVX2 well. It is recommended that the GCC compiler be later than 4.7. So we started the GCC upgrade.

Because Redhat 5.5 is installed on a virtual machine, the online upgrade cannot be completely solved. After several attempts, the following process is feasible.

The main reference is as follows:

Http://blog.sciencenet.cn/blog-714229-600604.html

Http://blog.sciencenet.cn/blog-714229-600389.html

Http://blog.rekfan.com/articles/13.html

GCC download Source: http://ftp.gnu.org/gnu/gcc/

Yum download Source: http://mirror.centos.org/centos-5/5.10/ OS /x86_64/CentOS/


1. Install the GCC dependency Library

(1) install gmp
Downloading gmp: http://gmplib.org/
# Mkdir-p/opt/gmp-4.3.2
# Tar-jxvf gmp-4.3.2.tar.bz2
# Cd gmp-4.3.2
#./Configure -- prefix =/opt/gmp-4.3.2
# Make & make check & make install
(2) install mpfr
Download mpfr http://www.mpfr.org/mpfr-current/#download
# Mkdir-p/opt/mpfr-2.4.2
# Tar-jxvf mpfr-2.4.2.tar.bz2
# Cd mpfr-2.4.2
#./Configure -- prefix =/opt/mpfr-2.4.2 -- with-gmp =/opt/gmp-4.3.2
# Make & make check & make install
(3) install MCM
Download http://www.multiprecision.org/index.php? Prog = mpc & page = download
# Mkdir-p/opt/mpc-0.8.1
# Tar-zxvf mpc-0.8.1.tar.gz
# Cd mpc-0.8.1
#./Configure -- prefix =/opt/mpc-0.8.1 -- with-gmp =/opt/gmp-4.3.2 -- with-mpfr =/opt/mpfr-2.4.2
# Make & make check & make install
(4) build gcc
# Export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/opt/gmp-4.3.2/lib:/opt/mpfr-2.4.2/lib:/opt/mpc-0.8.1/lib

Ii. Use Yum to install guile

(1) uninstall rhel's default yum package
View yum package
Rpm-qa | grep yum
Detach
Rpm-qa | grep yum | xargs rpm-e -- nodeps


(2) download the new yum package
Download the installation package for 64-bit linux
Wget http://mirror.centos.org/centos-5/5.10/ OS /x86_64/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm
Wget http://mirror.centos.org/centos-5/5.10/ OS /x86_64/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
Wget http://mirror.centos.org/centos-5/5.10/ OS /x86_64/CentOS/yum-metadata-parser-1.1.2-4.el5.x86_64.rpm



Then install
Rpm-ivh yum -*
Note: yum and yum-fastestmirror are mutually dependent, so install them at the same time.
(3) download the configuration source of yum
Download the wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo to the/etc/yum. repos. d/directory


(4) Run yum makecache to generate Cache


(5) yum install guile


Iii. install autogen

Libxml2-devel may be missing during installation, guile-devel, upgrade with yum install xx


Download http://rpm.pbone.net/index.php3/stat/26/dist/55/size/1314516/name/autogen-5.8.9-1.el5.kb.src.rpm
. Src. rpm Installation Method
# Rpm-I you-package.src.rpm
# Cd/usr/src/redhat/SPECS (the first two steps are the same as method 1)
# Rpmbuild-bb your-package.specs A specs file with the same name as your package

In this case, under the directory/usr/src/redhat/RPM/i386/(depending on the specific package, it may be i686, noarch, etc, there is a new rpm package, which is a compiled binary file. Run:

# Rpm-I new-package.rpm installation is complete. Reference http://blog.csdn.net/lphpc/article/details/565823


4. Install GCC4.7

(1) # mkdir-p/opt/gcc-4.7
# Mkdir gcc_build (in the GCC source code directory)

(2 ).. /configure -- prefix =/opt/gcc-4.7-enable-threads = posix-disable-checking-disable-multilib-enable-versions ages = c, c ++ -- with-gmp =/opt/gmp-4.3.2 -- with-mpfr =/opt/mpfr-2.4.2 -- with-mpc =/opt/mpc-0.8.1

(3) After the success, generate the Makefile file, and then directly make, OK ----- wait -----

(4) make install

To re-compile make clean, clear the files left behind by the previous compilation.

Uninstallation

If the old version is rpm, check the version gcc -- version and delete rpm-e.

If the old version is installed with the source code, check the path of whereis gcc or which gcc and delete it.

Set the tool chain:

Connect the command file symbol to the/usr/bin directory:

  1. # Cd/usr/bin

  2. # Ln-sv/usr/local/gcc-4.7.1/bin/gcc (if there is a duplicate, directly Delete the original gcc)

  3. # Ln-sv/usr/local/gcc-4.7.1/bin/g ++


  4. Library File Settings:

    Add/usr/local/gcc-4.7.1/lib path to environment variable LD_LIBRARY_PATH

    1. # Vi/etc/profile

      Add the following code

      Setenv LD_LIBRARY_PATH/usr/local/gcc-4.7.1/lib: $ LD_LIBRARY_PATH

      Cleaning site

      1. # Rm-rf gcc-4.7.1

      2. # Rm-rf gcc-B

        Installation is complete.
        You can use gcc-v to check whether the version is 4.7.1 or not.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.