小樱 发表于 2024/12/26 02:43

Linux centos php8.1编译报错libxml,更新gcc v5.5.0版本,对应vs2019 c++20 和binutils的as汇编器v2.38

Linux centos php8.1编译报错libxml,更新gcc v5.5.0版本,对应vs2019 c++20 和binutils的as汇编器v2.38

/bin/sh /root/php-8.1.31/libtool --silent --preserve-dup-deps --tag CC --mode=compile cc -std=gnu99 -Iext/libxml/ -I/root/php-8.1.31/ext/libxml/ -I/root/php-8.1.31/include -I/root/php-8.1.31/main -I/root/php-8.1.31 -I/root/php-8.1.31/ext/date/lib -I/usr/local/include/libxml2 -I/usr/local/include -I/usr/include/libpng12 -I/root/php-8.1.31/ext/mbstring/libmbfl -I/root/php-8.1.31/ext/mbstring/libmbfl/mbfl -I/root/php-8.1.31/TSRM -I/root/php-8.1.31/Zend    -fno-common -Wstrict-prototypes -Wlogical-op -Wno-clobbered -Wall -Wextra -Wno-strict-aliasing -Wno-unused-parameter -Wno-sign-compare -g -O2 -fvisibility=hidden -DZEND_SIGNALS   -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -c /root/php-8.1.31/ext/libxml/libxml.c -o ext/libxml/libxml.lo-MMD -MF ext/libxml/libxml.dep -MT ext/libxml/libxml.lo
In file included from /root/php-8.1.31/ext/libxml/libxml.c:43:
/root/php-8.1.31/ext/libxml/php_libxml.h: 在函数‘php_libxml_sanitize_parse_ctxt_options’中:
/root/php-8.1.31/ext/libxml/php_libxml.h:170: 错误:#pragma GCC diagnostic 不允许用在函数体中
/root/php-8.1.31/ext/libxml/php_libxml.h:170: 错误:#pragma GCC diagnostic 不允许用在函数体中
/root/php-8.1.31/ext/libxml/php_libxml.h:178: 错误:#pragma GCC diagnostic 不允许用在函数体中
make: *** 错误 1

好像是php自身的问题,联系官方后得知是gcc 4.4.7版本的问题,gcc需要依赖GMP、MPFR、MPC,由于gcc v10.1.0版本开始要求高版本MPFR,为了直接yum方便开发库,所以就用v9.5.0啦
编译最少需要2G内存,经过优化的编译参数,不过由于支持多个高版本c++,所以还是很花时间,v9.5.0 4核心cpu花费29分钟左右完成,而且不支持一些古老程序的编译,所以这里建议用v5.5.0
yum -y install wget bzip2 make automake gcc gcc-c++ gmp-devel mpfr-devel libmpc-devel
wget https://mirrors.aliyun.com/gnu/gcc/gcc-5.5.0/gcc-5.5.0.tar.gz
tar zxf gcc-5.5.0.tar.gz
cd gcc-5.5.0
./configure --enable-checking=release --enable-languages=c,c++ --disable-multilib --with-system-zlib --disable-nls
make -j 4
make install
rm -rf /usr/bin/gcc.OFF
mv /usr/bin/gcc /usr/bin/gcc.OFF
ln -s /usr/local/bin/gcc /usr/bin/gcc
/usr/bin/gcc --version

检查版本
gcc --version
gcc (GCC) 5.5.0
Copyright (C) 2015 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.


然后报错内容发生了改变
/bin/sh /root/php-8.1.31/libtool --silent --preserve-dup-deps --tag CC --mode=install cp ext/opcache/opcache.la /root/php-8.1.31/modules
/bin/sh /root/php-8.1.31/libtool --silent --preserve-dup-deps --tag CC --mode=compile cc -Iext/standard/ -I/root/php-8.1.31/ext/standard/ -I/root/php-8.1.31/include -I/root/php-8.1.31/main -I/root/php-8.1.31 -I/root/php-8.1.31/ext/date/lib -I/usr/local/include/libxml2 -I/usr/local/include -I/usr/include/libpng12 -I/root/php-8.1.31/ext/mbstring/libmbfl -I/root/php-8.1.31/ext/mbstring/libmbfl/mbfl -I/root/php-8.1.31/TSRM -I/root/php-8.1.31/Zend    -fno-common -Wstrict-prototypes -Wformat-truncation -Wlogical-op -Wduplicated-cond -Wno-clobbered -Wall -Wextra -Wno-strict-aliasing -Wno-unused-parameter -Wno-sign-compare -g -O2 -fvisibility=hidden -Wimplicit-fallthrough=1 -DZEND_SIGNALS   -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -c /root/php-8.1.31/ext/standard/base64.c -o ext/standard/base64.lo-MMD -MF ext/standard/base64.dep -MT ext/standard/base64.lo
/tmp/ccIN3E2O.s: Assembler messages:
/tmp/ccIN3E2O.s:467: Error: no such instruction: `vinserti128 $0x1,-8(%rbx),%ymm3,%ymm1'
/tmp/ccIN3E2O.s:501: Error: no such instruction: `vpermd %ymm1,%ymm0,%ymm1'
/tmp/ccIN3E2O.s:538: Error: suffix or operands invalid for `vpshufb'
/tmp/ccIN3E2O.s:591: Error: suffix or operands invalid for `vpand'
/tmp/ccIN3E2O.s:597: Error: suffix or operands invalid for `vpmulhuw'
/tmp/ccIN3E2O.s:636: Error: suffix or operands invalid for `vpand'
/tmp/ccIN3E2O.s:642: Error: suffix or operands invalid for `vpmullw'
/tmp/ccIN3E2O.s:648: Error: suffix or operands invalid for `vpor'
/tmp/ccIN3E2O.s:684: Error: suffix or operands invalid for `vpcmpgtb'
/tmp/ccIN3E2O.s:691: Error: suffix or operands invalid for `vpsubusb'
/tmp/ccIN3E2O.s:724: Error: suffix or operands invalid for `vpsubb'
/tmp/ccIN3E2O.s:731: Error: suffix or operands invalid for `vpshufb'
/tmp/ccIN3E2O.s:753: Error: suffix or operands invalid for `vpaddb'
/tmp/ccIN3E2O.s:763: Error: no such instruction: `vextracti128 $0x1,%ymm0,40(%rax)'
/tmp/ccIN3E2O.s:823: Error: no such instruction: `vinserti128 $0x1,-12(%rbx),%ymm1,%ymm1'
/tmp/ccIN3E2O.s:831: Error: suffix or operands invalid for `vpshufb'
/tmp/ccIN3E2O.s:864: Error: suffix or operands invalid for `vpand'
/tmp/ccIN3E2O.s:870: Error: suffix or operands invalid for `vpmulhuw'
/tmp/ccIN3E2O.s:909: Error: suffix or operands invalid for `vpand'
/tmp/ccIN3E2O.s:915: Error: suffix or operands invalid for `vpmullw'
/tmp/ccIN3E2O.s:921: Error: suffix or operands invalid for `vpor'
/tmp/ccIN3E2O.s:957: Error: suffix or operands invalid for `vpcmpgtb'
/tmp/ccIN3E2O.s:964: Error: suffix or operands invalid for `vpsubusb'
/tmp/ccIN3E2O.s:997: Error: suffix or operands invalid for `vpsubb'
/tmp/ccIN3E2O.s:1003: Error: suffix or operands invalid for `vpshufb'
/tmp/ccIN3E2O.s:1025: Error: suffix or operands invalid for `vpaddb'
/tmp/ccIN3E2O.s:1035: Error: no such instruction: `vextracti128 $0x1,%ymm0,-16(%rdx)'
/tmp/ccIN3E2O.s:2054: Error: suffix or operands invalid for `vpcmpeqb'
/tmp/ccIN3E2O.s:2066: Error: suffix or operands invalid for `vpaddb'
/tmp/ccIN3E2O.s:2072: Error: suffix or operands invalid for `vpshufb'
/tmp/ccIN3E2O.s:2106: Error: suffix or operands invalid for `vpaddb'
/tmp/ccIN3E2O.s:2115: Error: suffix or operands invalid for `vpmaddubsw'
/tmp/ccIN3E2O.s:2133: Error: suffix or operands invalid for `vpmaddwd'
/tmp/ccIN3E2O.s:2152: Error: suffix or operands invalid for `vpshufb'
/tmp/ccIN3E2O.s:2171: Error: no such instruction: `vpermd %ymm0,%ymm6,%ymm0'
/tmp/ccIN3E2O.s:2183: Error: no such instruction: `vextracti128 $0x1,%ymm0,40(%rax,%rdx)'
/tmp/ccIN3E2O.s:2211: Error: no such instruction: `vinserti128 $0x1,16(%rbx),%ymm0,%ymm10'
/tmp/ccIN3E2O.s:2239: Error: suffix or operands invalid for `vpsrld'
/tmp/ccIN3E2O.s:2247: Error: suffix or operands invalid for `vpand'
/tmp/ccIN3E2O.s:2270: Error: suffix or operands invalid for `vpand'
/tmp/ccIN3E2O.s:2276: Error: suffix or operands invalid for `vpshufb'
/tmp/ccIN3E2O.s:2285: Error: suffix or operands invalid for `vpshufb'
make: *** 错误 1

开发者回复说是binutils版本太低,发现能升级的最高版本是v2.38
查看系统自带为binutils-2.20.51.0.2-5.48.el6_10.1.x86_64
yum -y install wget bzip2 make automake gcc gcc-c++ texinfo
wget https://mirrors.aliyun.com/gnu/binutils/binutils-2.38.tar.gz
tar zxf binutils-2.38.tar.gz
cd binutils-2.38
./configure --with-system-zlib --disable-nls
make -j 4
make install
rm -rf /usr/bin/as.OFF
mv /usr/bin/as /usr/bin/as.OFF
ln -s /usr/local/bin/as /usr/bin/as
/usr/bin/as --version

检查汇编器版本
as --version
GNU assembler (GNU Binutils) 2.38
Copyright (C) 2022 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-pc-linux-gnu'.

然后在编译安装php8.1就成功了,没想到变化这么大官方网站居然没列举出来

不同版本gcc的区别
https://bbs.itzmx.com/thread-111156-1-1.html

页: [1]
查看完整版本: Linux centos php8.1编译报错libxml,更新gcc v5.5.0版本,对应vs2019 c++20 和binutils的as汇编器v2.38