gcc glibc升級

爲防止升級glibc失敗,備份好系統庫,失敗後可以將備份的目錄拷回來。恢復系統(rescue or將盤掛到別的機器)

需備分的目錄:/lib,/usr/lib,/usr/include,/usr/sbin和/usr/bin,/lib64 ,/usr/lib64/

由於在集羣上的ld都是2.20版 本。在glibc configure的時候會報version of ld... 2.20.51.0.2, bad 所以要先升級ld

/global/share/binutils-2.26.tar.gz

[root@test binutils-2.26]# ./configure --prefix=/usr --enable-ld

make

make instlal

確認版本升級成功

[root@test binutils-2.26]# ld -v

GNU ld (GNU Binutils) 2.26.20160125

安裝gcc

因爲集羣上的gcc是4.4版本,所以也要升級。安裝glibc時報錯 checking if gcc is sufficient to build libc... no checking for nm... nm configure: error: *** These critical programs are missing or too old: compiler *** Check the INSTALL file for required versions.

/global/share/gcc-4.9.0-full.tar.gz (因集羣上不能***,將升級gcc所需的mpfr、mpc、gmp、isl、cloog tar包已經打包進去)

sh -x ./contrib/download_prerequisites(腳本中已經註釋掉wget過程,解壓mpfr、mpc、gmp、isl、cloog,做軟鏈)

cd ..

mkdir objdir

cd objdir

../gcc-4.9.0-full/configure --prefix=/usr --enable-languages=c,c++,fortran,go --disable-multilib(注意這裏指定的--prefix=/usr,好多同學都選擇默認安裝到/usr/bin/local下,造成失敗 。另外make時間較長,建議開screen執行)

make

make install

安裝完成後,查看gcc版本已經變成4.9

安裝glibc

tar -zxf /global/share/glibc-2.23.tar.gz

cd glibc-2.23

mkdir build

../configure --prefix=/usr --disable-profile --enable-kernel=2.6.32 --enable-obsolete-rpc

make

make install

會跳出錯誤(我碰到是這樣的錯誤,還有可能是其它的錯誤,具體錯誤具體分析,但我認爲這些問題,基本上就是因爲升級後因爲軟鏈的版本不對所造成的)

gawk: error while loading shared libraries: /lib64/libm.so.6: invalid ELF header

make[2]: *** [/disk1/software/gcc/glibc-2.23/build/math/stubs] Error 127

make[2]: Leaving directory `/disk1/software/gcc/glibc-2.23/math'

make[1]: *** [math/subdir_install] Error 2

make[1]: Leaving directory `/disk1/software/gcc/glibc-2.23'

make: *** [install] Error 2

發現錯誤後,google了一圈,沒有找到相關的。就自已分析了一下,先cat了一下/lib64/libm.so.6發現瞭如下的內容:

/* GNU ld script*/OUTPUT_FORMAT(elf64-x86-64)GROUP ( /lib64/libm.so.6  AS_NEEDED ( /usr/lib64/libmvec_nonshared.a /lib64/libmvec.so.1 ) )

這個內容和正常的是不一樣的。而且是link到老的libm-2.12.so版本,ls grep了一下libm相關的文件,發現有新的libm-2.23.so文件生成,這個時候更改了一下軟鏈:

unlink libm.so.6

ln -s libm-2.23.so libm.so.6 (在另外的窗口中做的操作,make install的窗口已經不動了)

繼續make install

最後出來:Your new glibc installation seems to be ok.

升級成功。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章