Improved building mbstring on PHP 7.4#1124
Conversation
As of [PHP 7.4][1], the oniguruma library is no longer bundled with PHP, instead libonig needs to be available on the system. [1]: https://www.php.net/manual/en/migration74.other-changes.php#migration74.other-changes.mbstring
| $this->variants['mbstring'] = function (ConfigureParameters $params, Build $build, $value) { | ||
| $params = $params->withOption('--enable-mbstring'); | ||
|
|
||
| if ($build->compareVersion('5.4') >= 0 && !$build->isDisabledVariant('mbregex')) { |
There was a problem hiding this comment.
@morozov Is this for php-5.4 or php-7.4? It looks weird.
There was a problem hiding this comment.
It will cause following problems when building php-5.6.40. If I change the statement to $build->compareVersion('7.4') fixed the problem.
make '-j8' >> '/Users/mark/.phpbrew/build/php-5.6.40/build.log' 2>&1
Error: Make failed:
The last 5 lines in the log file:
3 errors generated.
make: *** [ext/mbstring/php_mbregex.lo] Error 1
make: *** Waiting for unfinished jobs....
2 warnings generated.
1 warning generated.
Please checkout the build log file for more details:
tail /Users/mark/.phpbrew/build/php-5.6.40/build.log
There was a problem hiding this comment.
Could you find why exactly it failed, maybe a few lines above in the log? It works fine for me:
./configure '--cache-file=/home/morozov/.phpbrew/cache/config.cache' '--prefix=/home/morozov/.phpbrew/php/php-5.6.40' '--with-config-file-path=/home/morozov/.phpbrew/php/php-5.6.40/etc' '--with-config-file-scan-dir=/home/morozov/.phpbrew/php/php-5.6.40/var/db' '--with-libdir=lib/x86_64-linux-gnu' '--with-bz2=/usr' '--with-curl=/usr' '--enable-fpm' '--with-gd=shared' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-freetype-dir=/usr' '--with-iconv' '--enable-mbstring' '--with-onig=/usr' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-mysql-sock=/var/run/mysqld/mysqld.sock' '--with-openssl=/usr' '--with-sqlite3' '--enable-soap' '--with-zlib=/usr' '--enable-dom' '--enable-libxml' '--with-libxml-dir=/usr' '--enable-simplexml' '--enable-xml' '--enable-xmlreader' '--enable-xmlwriter' '--with-xsl' '--enable-opcache' >> '/home/morozov/.phpbrew/build/php-5.6.40/build.log' 2>&1
===> Checking patches...
Checking patch for php5.3.29 multi-sapi
Checking patch for php5.3.x on 64bit machine when intl is enabled.
Checking patch for openssl dso linking patch
Checking patch for php5.6 with openssl 1.1.x patch.
---> Applying patch...
patching file ext/openssl/openssl.c
patching file ext/openssl/xp_ssl.c
patching file ext/phar/util.c
patching file ext/openssl/openssl.c
patch unexpectedly ends in middle of line
Hunk #1 succeeded at 651 with fuzz 1.
Done.
1 changes patched.
===> Building...
make >> '/home/morozov/.phpbrew/build/php-5.6.40/build.log' 2>&1
Build finished: 4.7 minutes.
There was a problem hiding this comment.
Here comes my phpbrew command and log
command
phpbrew --debug install --jobs "$(nproc)" 5.6.40 +default +dbs +dba +apxs2 +ftp +soap +gettext +exif +iconv +bz2 +zli
log
https://gist.github.com/markwu/520647ce338f3d8a0543a731e20c8152
There was a problem hiding this comment.
I only tried to build PHP 7.4 against Homebrew dependencies, and it worked for me as well. Judging by the log output, there might be an older version of oniguruma required for PHP 5.6.
There was a problem hiding this comment.
If it turns out that this is because of the incompatible version, we can either find a way to enforce the version of the library used to build PHP 5.6 or reopen #1132 and use the external library only if it's required (PHP 7.4).
There was a problem hiding this comment.
Okay, I think I found the problem.
PHP-5.6.40 and PHP-7.3.13 ships it's own oniguruma, but PHP-7.4.1 doesn't. It located under
~/.phpbrew/build/php-5.6.40/ext/mbstring/oniguruma
~/.phpbrew/build/php-7.3.13/ext/mbstring/oniguruma
I guess PHP-7.(0|1|2) ships with it's ownoniguruma, too.
But, PHP-5.6.40 can only build --enable-mbregex with it's shipped oniguruma, and php-7.3.13 can build --enable-mbregex with both shipped and external oniguruma
So, as you said, maybe we should reopen #1132 to force build previous PHP version (Before PHP-7.4.0) with it's own shipped oniguruma.
There was a problem hiding this comment.
That's why homebrew's php formula has additional oniguruma dependency after PHP-7.4.0.
As of PHP 7.4, the oniguruma library is no longer bundled with PHP, instead libonig needs to be available on the system.