编译glibc
原来glibc版本
编译前需要的环境:
CentOS7
gcc 8.3.0
gdb 8.3.0
make 4.0
binutils 2.39 (ld -v)
python 3.6.8
其他看INSTALL, 但有些版本也不易太高
shell
wget https://mirrors.aliyun.com/gnu/glibc/glibc-2.37.tar.gz
tar -zxf glibc-2.37.tar.gz
cd glibc-2.37/
mkdir build
cd build
export LD_LIBRARY_PATH=""
../configure --prefix=/usr/local/glibc2.37
make -j
make install
编译成功
编译glibc遇到的问题
1. 系统缺少bision

安装 bison
shell
yum install bison -y
2. make 版本太低


INSTALL 里要求4.0以上, 更新make, 并且需要把make连接到/usr/bin/目录下
shell
wget http://ftp.gnu.org/pub/gnu/make/make-4.0.tar.gz
tar zxf make-4.0.tar.gz
./configure --prefix=/usr/local/
make
make install
# 会在/usr/local/make4.0/bin 中找到编译的make
# 备份
mv /usr/local/bin/make /usr/local/bin/make1
# 可以拷贝或者软连接
cp /usr/local/bin/make /usr/bin/make
make -v

3. LD_LIBRARY_PATH shouldn't contain the current directory

不用配置路径, 在运行.../configure前临时export下 LD_LIBRARY_PATH
4. .../sysdeps/x86_64/multiarch/memchr-evex-base.S:229: Error: no such instruction: vpcmpneqb (64 * 4)(%rdi),%zmm17,%k1'
binutils 版本不匹配导致
更新binutils
shell
wget http://ftp.gnu.org/gnu/binutils/binutils-2.39.tar.gz
tar -xzvf binutils-2.39.tar.gz # 解压
cd binutils-2.39/ # 定位到Binutils的目录
./configure --prefix=/usr/local/binutils2.39 # 设置安装目录
make # GNU中的工具
make install # 执行安装命令
# 备份
mv /usr/bin/ld /usr/bin/ld_back
mv /usr/bin/as /usr/bin/as_back
# 软连接
ln -s /usr/local/binutils2.39/bin/as /usr/bin/as
ln -s /usr/local/binutils2.39/bin/ld /usr/bin/ld
编译遇到gprofng.texi makeinfo build failure on centos 7 , 替换两个文件解决