阿里龙蜥Anolis8升级glibc2.29

写在开头: 根据网上繁多文章整理自己遇到的问题给大家避免踩到相同坑

 

因为国产化的需求, 公司使用了龙蜥 Anolis8 操作系统,但系统自带的 glibc2.28 遇到一个应用需要升级, yum 无法升级需要源码编译升级

 

编译升级安装

1
2
3
4
5
6
7
8
9
10
11
12
13
wget https://mirrors.aliyun.com/gnu/glibc/glibc-2.30.tar.gz
tar -xvf glibc-2.30.tar.gz
#查看glibc需要的gcc,make,python,camke等等库是否满足要求
cat INSTALL |grep -E "later|newer"
 
 
cd glibc-2.30
 
mkdir -p build && cd build
../configure --prefix=/usr CFLAGS="-g -O2 -fPIC -funwind-tables"
 
编译
make -j4

 

避免失败提前修改源码

打开 glibc-2.30/scripts/test-installation.pl

将原先替换 128 行的

&& $name ne "nss_test1" && $name ne "libgcc_s") {

修改为:

&& $name ne "nss_test1" && $name ne "nss_test2" && $name ne "nss_nis" && $name ne "nss_nisplus" && $name ne "libgcc_s" && $name ne "nsl" ) {

 

安装

make install

 

验证

#最后使用 ldd 查看版本
ldd --version

ldd (GNU libc) 2.29
Copyright (C)
2019 Free Software Foundation, Inc.
This is
free software; see the source for copying conditions. There is NO
warranty; not even
for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

或者
strings /lib64/libc.so.6 |egrep '^GLIBC_'

能看到 GLIBC_2.29 表示升级成功

 

FAQ

1、 安装目录直接使用 /usr, 不必 ldconfig 配置, 减少出错

2、 误删除软链接 /lib64/libc.so.6, 使用 ldconfig -l -v /lib64/libc-2.28.so 恢复

3、 遇到“段错误 (核心已转储)”等编译安装完出错请参考 2, 恢复 libc.so.6

 

参考链接:

1、 https://hexo.ittwtti.com/posts/56202/index.html

2、 https://blog.csdn.net/SHAOYEZUIZUISHAUI/article/details/135283978