macOS Big Sur 11.1 phpenv ビルドエラー
前提
anyenv + phpenv で php 7.4.9 などをインストールしようとした時のお話し
この辺のビルドに必要なライブラリはインストール
brew install bison re2c libxml2 zlib libzip bzip2 curl libiconv libedit pkg-config krb5 openssl@1.1 icu4c oniguruma
PATHやPKG_CONFIG_PATHも追加
~/.zshrc
export PATH=$HOME/.anyenv/bin:$PATH
eval "$(anyenv init -)"
export PATH="/usr/local/opt/bison/bin:$PATH"
export PATH="/usr/local/opt/libxml2/bin:$PATH"
export PATH="/usr/local/opt/bzip2/bin:$PATH"
export PATH="/usr/local/opt/curl/bin:$PATH"
export PATH="/usr/local/opt/libiconv/bin:$PATH"
export PATH="/usr/local/opt/krb5/bin:$PATH"
export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"
export PATH="/usr/local/opt/icu4c/bin:$PATH"
export PKG_CONFIG_PATH="/usr/local/opt/krb5/lib/pkgconfig:$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig:$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig:$PKG_CONFIG_PATH"
エラー① phpのビルドでエラー
% phpenv install 7.4.9
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded github Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: Loaded zendopcache Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 7.4.9 into /Users/hoge/.anyenv/envs/phpenv/versions/7.4.9
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.4.9.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.4.9
![Compiling]: /var/tmp/php-build/source/7.4.9
-----------------
| BUILD ERROR |
-----------------
Here are the last 10 lines from the log:
-----------------------------------------
tz->getOffset(now, FALSE, rawOffset, dstOffset, uec);
^
1 error generated.
make: *** [ext/intl/timezone/timezone_class.lo] Error 1
make: *** Waiting for unfinished jobs....
/var/tmp/php-build/source/7.4.9/ext/intl/timezone/timezone_methods.cpp:98:57: error: use of undeclared identifier 'FALSE'
tz = timezone_convert_datetimezone(tzobj->type, tzobj, FALSE, NULL,
^
1 error generated.
make: *** [ext/intl/timezone/timezone_methods.lo] Error 1
-----------------------------------------
The full Log is available at '/tmp/php-build.7.4.9.20210318081840.log'.
[Warn]: Aborting build.
エラー①の対策:CPPFLAGSに、U_DEFINE_FALSE_AND_TRUEを追加
~/.zshrc
export CPPFLAGS="-DU_DEFINE_FALSE_AND_TRUE=1"
エラー② xdebugのビルドでエラー
% source ~/.zshrc
% phpenv install 7.4.9
phpenv: /Users/hoge/.anyenv/envs/phpenv/versions/7.4.9 already exists
continue with installation? (y/N) y
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded github Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: Loaded zendopcache Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 7.4.9 into /Users/hoge/.anyenv/envs/phpenv/versions/7.4.9
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.4.9.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.4.9
[Compiling]: /var/tmp/php-build/source/7.4.9
[xdebug]: Installing version 3.0.3
[Skipping]: Already downloaded http://xdebug.org/files/xdebug-3.0.3.tgz
[xdebug]: Compiling xdebug in /var/tmp/php-build/source/xdebug-3.0.3
-----------------
| BUILD ERROR |
-----------------
Here are the last 10 lines from the log:
-----------------------------------------
^~~~
main/php_network.h:320:56: note: passing argument to parameter 'name' here
PHPAPI struct hostent* php_network_gethostbyname(char *name);
^
1 warning generated.
warning: no debug symbols in executable (-arch x86_64)
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: ext/opcache/.libs/opcache.a(shared_alloc_shm.o) has no symbols
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: ext/opcache/.libs/opcache.a(shared_alloc_shm.o) has no symbols
/Library/Developer/CommandLineTools/usr/bin/ranlib: file: /var/tmp/php-build/source/7.4.9/modules/opcache.a(shared_alloc_shm.o) has no symbols
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
-----------------------------------------
The full Log is available at '/tmp/php-build.7.4.9.20210318082619.log'.
[Warn]: Aborting build.
エラー②の対策:autoconfをインストール
brew install autoconf
成功!
% phpenv install 7.4.9
phpenv: /Users/hoge/.anyenv/envs/phpenv/versions/7.4.9 already exists
continue with installation? (y/N) y
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded github Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: Loaded zendopcache Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 7.4.9 into /Users/hoge/.anyenv/envs/phpenv/versions/7.4.9
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.4.9.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.4.9
[Compiling]: /var/tmp/php-build/source/7.4.9
[xdebug]: Installing version 3.0.3
[Skipping]: Already downloaded http://xdebug.org/files/xdebug-3.0.3.tgz
[xdebug]: Compiling xdebug in /var/tmp/php-build/source/xdebug-3.0.3
[xdebug]: Installing xdebug configuration in /Users/hoge/.anyenv/envs/phpenv/versions/7.4.9/etc/conf.d/xdebug.ini
[xdebug]: Cleaning up.
Makefile:228: warning: overriding commands for target `test'
Makefile:132: warning: ignoring old commands for target `test'
[Info]: Enabling Opcache...
[Info]: Done
[Info]: The Log File is not empty, but the Build did not fail. Maybe just warnings got logged. You can review the log in /tmp/php-build.7.4.9.20210318083125.log or rebuild with '--verbose' option
[Success]: Built 7.4.9 successfully.
違うバージョンをインストールするとまた別のエラー出るのかも・・・
7.2系に関してはこちらの記事が参考になります。
https://blog.ttskch.com/mac-catalina-big-sur-phpenv-php-build-error-under-php72/