首页 > 解决方案 > MacOS 上 php 7.4 的 Pecl 扩展编译错误

问题描述

我正在尝试在最新的 Mac OS for php 7.4 上安装 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,__MAC_10_11,__IPHONE_NA,__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。发生同样的错误。

标签: phpmacoscmakepecl

解决方案


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


推荐阅读