问题:
CentOS 7上编译Fastdfs libfastcommon,出现Error: expecting string instruction after `rep'错误。
[root@localhost libfastcommon-1.0.35]#./make.sh
cc -Wall -D_FILE_OFFSET_BITS=64-D_GNU_SOURCE -g -O3 -c -o hash.o hash.c
/tmp/ccG7CWvO.s: Assembler messages:
/tmp/ccG7CWvO.s:272: Error: expectingstring instruction after `rep'
/tmp/ccG7CWvO.s:3637: Error: expectingstring instruction after `rep'
/tmp/ccG7CWvO.s:3641: Error: expectingstring instruction after `rep'
/tmp/ccG7CWvO.s:3678: Error: expectingstring instruction after `rep'
/tmp/ccG7CWvO.s:3682: Error: expectingstring instruction after `rep'
/tmp/ccG7CWvO.s:3719: Error: expectingstring instruction after `rep'
...
解决:
解决的思路如下,根据jtlim的回答“The problem is that gcc 4.8 is generating "rep; ret" instructions to avoid a performance penalty for AMD chips. Older assemblers detect this as an error.”,该问题应该和GCC编译器有关,又根据Tim Croydon 的提示“Ran yum update binutils which took it to 2.23.52.0.1 and my problem went away. Not sure which version it was before unfortunately. ”,问题可能出在binutils包上。
于是,决定恢复binutils包,CentOS7 本身自带的为binutils-2.23版本,但发现了2.20的老版本。于是,决定删除老版本,恢复自身版本。
使用rpm -e binutils...删除老版本时,会因为被其他包依赖,不能被删除,采取rpm -ivh --force binutils...的方法强制安装2.23版本,然后再删除,就可以成功了。
步骤如下:
1、 查看已经安装的binutils
[root@localhost~]# rpm -qa | grep binutils
devtoolset-3-binutils-2.24-18.el7.x86_64
binutils-2.23.52.0.1-55.el7.x86_64
devtoolset-2-binutils-2.23.52.0.1-10.el6.x86_64
binutils-2.20.51.0.2-5.42.el6.x86_64
devtoolset-6-binutils-2.27-10.el7.x86_64
2、删除旧版本的binutils:
[root@localhost~]# rpm -e binutils-2.20.51.0.2-5.42.el6.x86_64
olset-6-binutils-2.27-10.el7.x86_64
若不能删除,强制用binutils-2.23版本覆盖:
[root@localhost~]# rpm -ivh --force/usr/nariis/Packages/binutils-2.23.52.0.1-55.el7.x86_64.rpm
警告:/usr/nariis/Packages/binutils-2.23.52.0.1-55.el7.x86_64.rpm:头V3 RSA/SHA256 Signature,密钥 ID f4a80eb5: NOKEY
准备中...################################# [100%]
正在升级/安装...
1:binutils-2.23.52.0.1-55.el7 ################################# [100%]
[root@localhost~]# rpm -qa | grep binutils
devtoolset-3-binutils-2.24-18.el7.x86_64
binutils-2.23.52.0.1-55.el7.x86_64
devtoolset-2-binutils-2.23.52.0.1-10.el6.x86_64
3、再次编译libfastcommon,OK。
参考:
1、thedarkside ofthemoon. Casablanca: Assembly error gcc 4.8.1 on linux centos.https://stackoverflow.com/questions/23561136/casablanca-assembly-error-gcc-4-8-1-on-linux-centos
原文链接:https://www.f2er.com/centos/377265.html