如何解决MacOS上php 7.4的Pecl扩展名编译错误
我正在尝试在用于PHP 7.4的最新Mac OS上安装pecl mongodb和memcached扩展。
得到相同的错误:
pecl install memcached
...
creating libtool
appending configuration tag "CXX" to libtool
configure: patching config.h.in
configure: creating ./config.status
config.status: creating config.h
running: make
/bin/sh /private/tmp/pear/temp/pear-build-timurbYTemI/memcached-3.1.5/libtool --mode=compile cc -I/usr/local/Cellar/PHP/7.4.11/include/PHP -I. -I/private/tmp/pear/temp/memcached -DPHP_ATOM_INC -I/private/tmp/pear/temp/pear-build-timurbYTemI/memcached-3.1.5/include -I/private/tmp/pear/temp/pear-build-timurbYTemI/memcached-3.1.5/main -I/private/tmp/pear/temp/memcached -I/usr/local/Cellar/PHP/7.4.11/include/PHP -I/usr/local/Cellar/PHP/7.4.11/include/PHP/main -I/usr/local/Cellar/PHP/7.4.11/include/PHP/TSRM -I/usr/local/Cellar/PHP/7.4.11/include/PHP/Zend -I/usr/local/Cellar/PHP/7.4.11/include/PHP/ext -I/usr/local/Cellar/PHP/7.4.11/include/PHP/ext/date/lib -I/usr/local/opt/zlib/include -I/usr/local/Cellar/libmemcached/1.0.18_2/include -I/usr/local/opt/PHP@7.4/include -DHAVE_CONfig_H -g -O2 -I/usr/local/Cellar/PHP/7.4.11/include/PHP -I/usr/local/Cellar/PHP/7.4.11/include/PHP/main -I/usr/local/Cellar/PHP/7.4.11/include/PHP/TSRM -I/usr/local/Cellar/PHP/7.4.11/include/PHP/Zend -I/usr/local/Cellar/PHP/7.4.11/inclu
de/PHP/ext -I/usr/local/Cellar/PHP/7.4.11/include/PHP/ext/date/lib -I/usr/local/opt/zlib/include -I/usr/local/Cellar/libmemcached/1.0.18_2/include -c /private/tmp/pear/temp/memcached/PHP_memcached.c -o PHP_memcached.lo
mkdir .libs
cc -I/usr/local/Cellar/PHP/7.4.11/include/PHP -I. -I/private/tmp/pear/temp/memcached -DPHP_ATOM_INC -I/private/tmp/pear/temp/pear-build-timurbYTemI/memcached-3.1.5/include -I/private/tmp/pear/temp/pear-build-timurbYTemI/memcached-3.1.5/main -I/private/tmp/pear/temp/memcached -I/usr/local/Cellar/PHP/7.4.11/include/PHP -I/usr/local/Cellar/PHP/7.4.11/include/PHP/main -I/usr/local/Cellar/PHP/7.4.11/include/PHP/TSRM -I/usr/local/Cellar/PHP/7.4.11/include/PHP/Zend -I/usr/local/Cellar/PHP/7.4.11/include/PHP/ext -I/usr/local/Cellar/PHP/7.4.11/include/PHP/ext/date/lib -I/usr/local/opt/zlib/include -I/usr/local/Cellar/libmemcached/1.0.18_2/include -I/usr/local/opt/PHP@7.4/include -DHAVE_CONfig_H -g -O2 -I/usr/local/Cellar/PHP/7.4.11/include/PHP -I/usr/local/Cellar/PHP/7.4.11/include/PHP/main -I/usr/local/Cellar/PHP/7.4.11/include/PHP/TSRM -I/usr/local/Cellar/PHP/7.4.11/include/PHP/Zend -I/usr/local/Cellar/PHP/7.4.11/include/PHP/ext -I/usr/local/Cellar/PHP/7.4.11/include/PHP/ext/date/lib -I/usr/local/opt/zlib/include
-I/usr/local/Cellar/libmemcached/1.0.18_2/include -c /private/tmp/pear/temp/memcached/PHP_memcached.c -fno-common -DPIC -o .libs/PHP_memcached.o
In file included from /private/tmp/pear/temp/memcached/PHP_memcached.c:22:
In file included from /private/tmp/pear/temp/memcached/PHP_memcached.h:20:
In file included from /usr/local/Cellar/PHP/7.4.11/include/PHP/main/PHP.h:33:
In file included from /usr/local/Cellar/PHP/7.4.11/include/PHP/Zend/zend.h:356:
/usr/local/Cellar/PHP/7.4.11/include/PHP/Zend/zend_operators.h:523:10: error: 'asm goto' constructs are not supported yet
__asm__ goto(
^
/usr/local/Cellar/PHP/7.4.11/include/PHP/Zend/zend_operators.h:586:10: error: 'asm goto' constructs are not supported yet
__asm__ goto(
^
/usr/local/Cellar/PHP/7.4.11/include/PHP/Zend/zend_operators.h:656:10: error: 'asm goto' constructs are not supported yet
__asm__ goto(
^
/usr/local/Cellar/PHP/7.4.11/include/PHP/Zend/zend_operators.h:766:10: error: 'asm goto' constructs are not supported yet
__asm__ goto(
^
/private/tmp/pear/temp/memcached/PHP_memcached.c:482:6: warning: 'sasl_client_init' is deprecated: first deprecated in macOS 10.11 [-Wdeprecated-declarations]
if (sasl_client_init(NULL) != SASL_OK) {
^
/Library/Developer/CommandLinetools/SDKs/MacOSX.sdk/usr/include/sasl/sasl.h:924:17: note: 'sasl_client_init' has been explicitly marked deprecated here
LIBSASL_API int sasl_client_init(const sasl_callback_t *callbacks) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_11,__IPHONE_NA,__IPHONE_NA);
^
/private/tmp/pear/temp/memcached/PHP_memcached.c:4631:3: warning: 'sasl_done' is deprecated: first deprecated in macOS 10.11 [-Wdeprecated-declarations]
sasl_done();
^
/Library/Developer/CommandLinetools/SDKs/MacOSX.sdk/usr/include/sasl/sasl.h:727:18: note: 'sasl_done' has been explicitly marked deprecated here
LIBSASL_API void sasl_done(void) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__IPHONE_NA);
^
2 warnings and 4 errors generated.
make: *** [PHP_memcached.lo] Error 1
ERROR: `make' Failed
这是编译器(clang !?)版本的东西吗?它与PHP 7.2兼容。但是对于PHP 7.3和7.4。发生同样的错误。
解决方法
为我安装Xcode 12命令行工具的工作。它将Clang更新到12版本。
另一个技巧是通过设置禁用asm goto运算符
# define ZEND_USE_ASM_ARITHMETIC 0
中的/usr/local/Cellar/php/7.4.11/include/php/Zend/zend_operators.h:508
disable asm goto运算符技巧对我有用,顺便说一句,我正在使用PHP 7.4.12。 我必须将下面的第一行从1更改为0:
# define ZEND_USE_ASM_ARITHMETIC 0
#else
# define ZEND_USE_ASM_ARITHMETIC 0
#endif
,
您可以尝试为XCode 12 here安装命令行工具。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。