alexeyrybak/blitz

make error php 8.1

Closed this issue · 7 comments

Hello, on php 8.1 with php8 branch have make error

#make
/bin/bash /usr/src/blitz/libtool --mode=compile cc -I. -I/usr/src/blitz -I/usr/src/blitz/include -I/usr/src/blitz/main -I/usr/src/blitz -I/usr/include/php/20210902 -I/usr/include/php/20210902/main -I/usr/include/php/20210902/TSRM -I/usr/include/php/20210902/Zend -I/usr/include/php/20210902/ext -I/usr/include/php/20210902/ext/date/lib  -DHAVE_CONFIG_H  -g -O2    -DZEND_COMPILE_DL_EXT=1 -c /usr/src/blitz/blitz.c -o blitz.lo  -MMD -MF blitz.dep -MT blitz.lo
libtool: compile:  cc -I. -I/usr/src/blitz -I/usr/src/blitz/include -I/usr/src/blitz/main -I/usr/src/blitz -I/usr/include/php/20210902 -I/usr/include/php/20210902/main -I/usr/include/php/20210902/TSRM -I/usr/include/php/20210902/Zend -I/usr/include/php/20210902/ext -I/usr/include/php/20210902/ext/date/lib -DHAVE_CONFIG_H -g -O2 -DZEND_COMPILE_DL_EXT=1 -c /usr/src/blitz/blitz.c -MMD -MF blitz.dep -MT blitz.lo  -fPIC -DPIC -o .libs/blitz.o
In file included from /usr/include/php/20210902/main/php.h:418,
                 from /usr/src/blitz/blitz.c:30:
/usr/src/blitz/blitz.c: In function ‘blitz_read_with_stream’:
/usr/src/blitz/blitz.c:375:77: error: ‘IGNORE_URL_WIN’ undeclared (first use in this function); did you mean ‘IGNORE_URL’?
     stream = php_stream_open_wrapper(filename, "rb", IGNORE_PATH|IGNORE_URL|IGNORE_URL_WIN|REPORT_ERRORS, NULL);
                                                                             ^~~~~~~~~~~~~~
/usr/include/php/20210902/main/php_streams.h:584:107: note: in definition of macro ‘php_stream_open_wrapper’
 #define php_stream_open_wrapper(path, mode, options, opened) _php_stream_open_wrapper_ex((path), (mode), (options), (opened), NULL STREAMS_CC)
                                                                                                           ^~~~~~~
/usr/src/blitz/blitz.c:375:77: note: each undeclared identifier is reported only once for each function it appears in
     stream = php_stream_open_wrapper(filename, "rb", IGNORE_PATH|IGNORE_URL|IGNORE_URL_WIN|REPORT_ERRORS, NULL);
                                                                             ^~~~~~~~~~~~~~
/usr/include/php/20210902/main/php_streams.h:584:107: note: in definition of macro ‘php_stream_open_wrapper’
 #define php_stream_open_wrapper(path, mode, options, opened) _php_stream_open_wrapper_ex((path), (mode), (options), (opened), NULL STREAMS_CC)
                                                                                                           ^~~~~~~
make: *** [Makefile:201: blitz.lo] Error 1
php -v
PHP 8.1.2 (cli) (built: Jan 27 2022 12:20:56) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2, Copyright (c), by Zend Technologies

Addition
Under php8.0 everything works fine, the problem is in 8.1.
We suspect that due to the fact that php_stream_open_wrapper was trouble in 8.1

As a quick fix try just to remove IGNORE_URL_WIN:
On Windows systems, this is equivalent to IGNORE_URL. On all other systems, this flag has no effect.
Literally,
php_stream_open_wrapper(filename, "rb", IGNORE_PATH|IGNORE_URL|REPORT_ERRORS, NULL);

Yeah, we also found this line and corrected it, it made it possible to make.
But not all tests passed. Additional, some tests do not pass under php 8.0 too.
Most likely, some tests have simply not been corrected for so long that they are not relevant.

fisher@fisher blitz % ./run-tests.sh | grep FAIL
FAIL returning non-strings from user methods [tests/return_non_string.phpt]
FAIL unprefixed variables syntax [tests/var_no_prefix.phpt]

do you have the same - only these two tests failed?

Tests failed : 2 ( 1.9%) ( 1.9%)
Tests passed : 102 ( 98.1%) ( 98.1%)

blitz.ini

extension=blitz.so
blitz.enable_comments = 1
blitz.enable_alternative_tags = 0
blitz.scope_lookup_limit = 8

Debian 11 Bullseye, PHP 8.1.2 CLI, Linux kernel 5.10.0-9-amd64

=================================================
Number of tests :  104               104
Tests skipped   :    0 (  0.0%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :   15 ( 14.4%) ( 14.4%)
Tests passed    :   89 ( 85.6%) ( 85.6%)
---------------------------------------------------------------------
Time taken      :    2 seconds
=================================================

=================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
clean [tests/clean.phpt]
clean_globals [tests/clean_globals.phpt]
user-defined methods [tests/method.phpt]
mix #1 [tests/mix1.phpt]
mix #4 [tests/mix4.phpt]
mix #5 [tests/mix5.phpt]
testing deep nesting [tests/nest_deep.phpt]
complex conditions [tests/old_style.phpt]
parse with iteration set [tests/parse_with_iterations.phpt]
partial php_templates syntax compability [tests/phpt_compability.phpt]
returning non-strings from user methods [tests/return_non_string.phpt]
scope test with magic variables (_top and _parent) [tests/scope4.phpt]
mixed set [tests/set_mixed.phpt]
spaces inside tags [tests/spaces.phpt]
iterate after wrong previous iterations [tests/wrong_iterations.phpt]
==================================================

Hm...
With defaults ini setting, is only one test fail

=====================================================================
Number of tests :  104               104
Tests skipped   :    0 (  0.0%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    1 (  1.0%) (  1.0%)
Tests passed    :  103 ( 99.0%) ( 99.0%)
---------------------------------------------------------------------
Time taken      :    1 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
returning non-strings from user methods [tests/return_non_string.phpt]
=====================================================================

With only

blitz.enable_alternative_tags = 0
=====================================================================
Number of tests :  104               104
Tests skipped   :    0 (  0.0%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :   11 ( 10.6%) ( 10.6%)
Tests passed    :   93 ( 89.4%) ( 89.4%)
---------------------------------------------------------------------
Time taken      :    2 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
clean [tests/clean.phpt]
clean_globals [tests/clean_globals.phpt]
user-defined methods [tests/method.phpt]
mix #4 [tests/mix4.phpt]
complex conditions [tests/old_style.phpt]
parse with iteration set [tests/parse_with_iterations.phpt]
partial php_templates syntax compability [tests/phpt_compability.phpt]
returning non-strings from user methods [tests/return_non_string.phpt]
mixed set [tests/set_mixed.phpt]
spaces inside tags [tests/spaces.phpt]
iterate after wrong previous iterations [tests/wrong_iterations.phpt]
=====================================================================

With only

blitz.scope_lookup_limit = 8
=====================================================================
Number of tests :  104               104
Tests skipped   :    0 (  0.0%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :    5 (  4.8%) (  4.8%)
Tests passed    :   99 ( 95.2%) ( 95.2%)
---------------------------------------------------------------------
Time taken      :    1 seconds
=====================================================================

=====================================================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
mix #1 [tests/mix1.phpt]
mix #5 [tests/mix5.phpt]
testing deep nesting [tests/nest_deep.phpt]
returning non-strings from user methods [tests/return_non_string.phpt]
scope test with magic variables (_top and _parent) [tests/scope4.phpt]
=====================================================================

Will close this as core compilation issue was fixed. If you think some of the test failures are bugs - please open new issues.