cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

[NFR]: PHP 8.2 support

Open Jeckerson opened this issue 2 years ago • 1 comments

Blocked by https://github.com/zephir-lang/zephir/issues/2370

Jeckerson avatar May 30 '22 22:05 Jeckerson

Used to build 5.0_rc4 for Alpinelinux, just a small patch allowed to build without errors

https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/37407/diffs#b79d2b5ff56a34ca9289565a23e8b9f62d3db676

https://gitlab.alpinelinux.org/alpine/aports/-/blob/cbcb3a88b4350e735f294d50f78163f13737bead/testing/php82-pecl-phalcon/fix-build.patch

andypost avatar Aug 09 '22 09:08 andypost

It still fails to build on PHP 8.2 with a huge log of warnings and notices

...
/usr/include/php82/Zend/zend_portability.h:364:52: note: in definition of macro 'UNEXPECTED'
  364 | # define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
      |                                                    ^~~~~~~~~
/usr/include/php82/Zend/zend_API.h:1944:9: note: in expansion of macro 'Z_PARAM_STR_EX'
 1944 |         Z_PARAM_STR_EX(dest, 0, 0)
      |         ^~~~~~~~~~~~~~
/home/buildozer/aports/testing/php82-pecl-phalcon/src/phalcon-5.0.0/phalcon.zep.c:218942:17: note: in expansion of macro 'Z_PARAM_STR'
218942 |                 Z_PARAM_STR(key)
       |                 ^~~~~~~~~~~
/usr/include/php82/Zend/zend_API.h:2106:76: note: expected 'zend_string **' {aka 'struct _zend_string **'} but argument is of type 'zval *' {aka 'struct _zval_struct *'}
 2106 | static zend_always_inline bool zend_parse_arg_str(zval *arg, zend_string **dest, bool check_null, uint32_t arg_num)
      |                                                              ~~~~~~~~~~~~~~^~~~
/home/buildozer/aports/testing/php82-pecl-phalcon/src/phalcon-5.0.0/phalcon.zep.c: In function 'zim_Phalcon_Annotations_Adapter_Stream_write':
/usr/include/php82/Zend/zend_API.h:1937:58: warning: passing argument 2 of 'zend_parse_arg_str' from incompatible pointer type [-Wincompatible-pointer-types]
 1937 |                 if (UNEXPECTED(!zend_parse_arg_str(_arg, &dest, check_null, _i))) { \
/usr/include/php82/Zend/zend_portability.h:364:52: note: in definition of macro 'UNEXPECTED'
  364 | # define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
      |                                                    ^~~~~~~~~
/usr/include/php82/Zend/zend_API.h:1944:9: note: in expansion of macro 'Z_PARAM_STR_EX'
 1944 |         Z_PARAM_STR_EX(dest, 0, 0)
      |         ^~~~~~~~~~~~~~
/home/buildozer/aports/testing/php82-pecl-phalcon/src/phalcon-5.0.0/phalcon.zep.c:219024:17: note: in expansion of macro 'Z_PARAM_STR'
219024 |                 Z_PARAM_STR(key)
       |                 ^~~~~~~~~~~
/usr/include/php82/Zend/zend_API.h:2106:76: note: expected 'zend_string **' {aka 'struct _zend_string **'} but argument is of type 'zval *' {aka 'struct _zval_struct *'}
 2106 | static zend_always_inline bool zend_parse_arg_str(zval *arg, zend_string **dest, bool check_null, uint32_t arg_num)
      |                                                              ~~~~~~~~~~~~~~^~~~
/home/buildozer/aports/testing/php82-pecl-phalcon/src/phalcon-5.0.0/phalcon.zep.c: In function 'php_zephir_init_globals':
/home/buildozer/aports/testing/php82-pecl-phalcon/src/phalcon-5.0.0/phalcon.zep.c:220757:57: warning: assignment to 'zend_string *' {aka 'struct _zend_string *'} from incompatible pointer type 'char *' [-Wincompatible-pointer-types]
220757 |         phalcon_globals->orm.resultset_prefetch_records = ZSTR_VAL(zend_string_init(ZEND_STRL("0"), 0));
       |                                                         ^
make: *** [Makefile:210: phalcon.lo] Error 1

See https://build.alpinelinux.org/buildlogs/build-edge-x86_64/testing/php82-pecl-phalcon/php82-pecl-phalcon-5.0.0-r0.log

andypost avatar Sep 23 '22 15:09 andypost

@andypost Yes, Zephir changes are required. Use this branch of Zephir to build and compile Phalcon - https://github.com/zephir-lang/zephir/tree/%232370-php8.2

Zephir:

cd zephir/
wget https://github.com/box-project/box/releases/download/4.0.2/box.phar
php box.phar compile
cp zephir.phar /path/to/cphalcon/

Phalcon:

cd /cphalcon
php zephir.phar generate
php zephir.phar compile -j8

Jeckerson avatar Sep 23 '22 15:09 Jeckerson

Updated Arch Linux today, and Phalcon no longer works or updates. Any news on supporting PHP v8.2.x yet? Or maybe at least a workaround that works? Previously used PHP 8.1.13 with Phalcon 5.1.2 and it worked good. Please don't recommend downgrade as a workaround ^_^

uname -r
6.1.7-arch1-1

php -v
PHP 8.2.1 (cli) (built: Jan  4 2023 16:37:54) (NTS)
Zend Engine v4.2.1

PECL Install Failed:

pecl install phalcon
pecl/phalcon requires PHP (version >= 7.4.1, version <= 8.1.99), installed version is 8.2.1
No valid packages found
install failed

Manual Compile Method 1 Failed:

sudo wget https://github.com/zephir-lang/zephir/releases/download/0.16.3/zephir.phar -O /usr/local/bin/zephir
sudo chmod a+x /usr/local/bin/zephir
git clone https://github.com/phalcon/cphalcon
cd cphalcon/
git checkout tags/v5.1.4 ./
zephir build
cat compile-errors.log

/home/build/cphalcon/ext/kernel/main.c: In function ‘zephir_function_exists’:                 
/home/build/cphalcon/ext/kernel/main.c:285:108: warning: comparison between pointer and integer
  285 |         if (zend_hash_str_exists(CG(function_table), Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)) != NULL) {
      |                                                                                                            ^~
/home/build/cphalcon/ext/kernel/main.c: In function ‘zephir_function_exists_ex’:
/home/build/cphalcon/ext/kernel/main.c:301:83: warning: comparison between pointer and integer
  301 |         if (zend_hash_str_exists(CG(function_table), function_name, function_len) != NULL) {
      |                                                                                   ^~
/home/build/cphalcon/ext/kernel/main.c: In function ‘zephir_get_arg’:
/home/build/cphalcon/ext/kernel/main.c:571:9: error: too many arguments to function ‘zend_forbid_dynamic_call’
  571 |     if (zend_forbid_dynamic_call("func_get_arg()") == FAILURE) {
      |         ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/php/main/php.h:35,
                 from /home/build/cphalcon/ext/kernel/main.c:16:
/usr/include/php/Zend/zend_API.h:782:39: note: declared here
  782 | static zend_always_inline zend_result zend_forbid_dynamic_call(void)
      |                                       ^~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:213: kernel/main.lo] Error 1
make: *** Waiting for unfinished jobs....
/home/build/cphalcon/ext/phalcon.c: In function ‘php_zephir_init_globals’:
/home/build/cphalcon/ext/phalcon.c:1340:57: warning: assignment to ‘zend_string *’ {aka ‘struct _zend_string *’} from incompatible pointer type ‘char *’ [-Wincompatible-pointer-types]
 1340 |         phalcon_globals->orm.resultset_prefetch_records = ZSTR_VAL(zend_string_init(ZEND_STRL("0"), 0));
      |                                                         ^
/home/build/cphalcon/ext/kernel/main.c: In function ‘zephir_function_exists’:
/home/build/cphalcon/ext/kernel/main.c:285:108: warning: comparison between pointer and integer
  285 |         if (zend_hash_str_exists(CG(function_table), Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)) != NULL) {
      |                                                                                                            ^~
/home/build/cphalcon/ext/kernel/main.c: In function ‘zephir_function_exists_ex’:
/home/build/cphalcon/ext/kernel/main.c:301:83: warning: comparison between pointer and integer
  301 |         if (zend_hash_str_exists(CG(function_table), function_name, function_len) != NULL) {
      |                                                                                   ^~
/home/build/cphalcon/ext/kernel/main.c: In function ‘zephir_get_arg’:
/home/build/cphalcon/ext/kernel/main.c:571:9: error: too many arguments to function ‘zend_forbid_dynamic_call’
  571 |     if (zend_forbid_dynamic_call("func_get_arg()") == FAILURE) {
      |         ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/php/main/php.h:35,
                 from /home/build/cphalcon/ext/kernel/main.c:16:
/usr/include/php/Zend/zend_API.h:782:39: note: declared here
  782 | static zend_always_inline zend_result zend_forbid_dynamic_call(void)
      |                                       ^~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:213: kernel/main.lo] Error 1

Manual Compile Method 2 Failed:

sudo wget https://github.com/zephir-lang/zephir/releases/download/0.16.3/zephir.phar -O /usr/local/bin/zephir
sudo chmod a+x /usr/local/bin/zephir
git clone https://github.com/phalcon/cphalcon
cd cphalcon/
git checkout tags/v5.1.4 ./
zephir fullclean
zephir compile
cd ext
phpize
./configure
make && make install

Errors Output:

/bin/sh /home/build/cphalcon/ext/libtool --mode=compile cc -I. -I/home/build/cphalcon/ext -I/home/build/cphalcon/ext/include -I/home/build/cphalcon/ext/main -I/home/build/cphalcon/ext -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2 -D_GNU_SOURCE    -DZEND_COMPILE_DL_EXT=1 -c /home/build/cphalcon/ext/kernel/main.c -o kernel/main.lo  -MMD -MF kernel/main.dep -MT kernel/main.lo
 cc -I. -I/home/build/cphalcon/ext -I/home/build/cphalcon/ext/include -I/home/build/cphalcon/ext/main -I/home/build/cphalcon/ext -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -D_GNU_SOURCE -DZEND_COMPILE_DL_EXT=1 -c /home/build/cphalcon/ext/kernel/main.c -MMD -MF kernel/main.dep -MT kernel/main.lo  -fPIC -DPIC -o kernel/.libs/main.o
/home/build/cphalcon/ext/kernel/main.c: In function ‘zephir_function_exists’:
/home/build/cphalcon/ext/kernel/main.c:285:108: warning: comparison between pointer and integer
  285 | s(CG(function_table), Z_STRVAL_P(function_name), Z_STRLEN_P(function_name)) != NULL) {
      |                                                                             ^~

/home/build/cphalcon/ext/kernel/main.c: In function ‘zephir_function_exists_ex’:
/home/build/cphalcon/ext/kernel/main.c:301:83: warning: comparison between pointer and integer
  301 |   if (zend_hash_str_exists(CG(function_table), function_name, function_len) != NULL) {
      |                                                                             ^~

/home/build/cphalcon/ext/kernel/main.c: In function ‘zephir_get_arg’:
/home/build/cphalcon/ext/kernel/main.c:571:9: error: too many arguments to function ‘zend_forbid_dynamic_call’
  571 |     if (zend_forbid_dynamic_call("func_get_arg()") == FAILURE) {
      |         ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/php/main/php.h:35,
                 from /home/build/cphalcon/ext/kernel/main.c:16:
/usr/include/php/Zend/zend_API.h:782:39: note: declared here
  782 | static zend_always_inline zend_result zend_forbid_dynamic_call(void)
      |                                       ^~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:213: kernel/main.lo] Error 1

Thanks.

ghost avatar Jan 24 '23 12:01 ghost

@Jeckerson link you provided is broken, it shows error page 404

ghost avatar Jan 28 '23 15:01 ghost

@v00v I guess he was referring to this PR which was merged into zephir development branch.

hakimio avatar Feb 12 '23 13:02 hakimio

Yes, and there's new release https://github.com/zephir-lang/zephir/releases/tag/0.17.0

andypost avatar Feb 12 '23 13:02 andypost

Used to build from https://github.com/phalcon/cphalcon/archive/44119cf8b3b286b15ad7d6405ad9e1f443d3bc09.tar.gz on Alpinelinux, it's required export CFLAGS="$CFLAGS -DALPINE_LINUX=1" to skip execinfo miss according to https://github.com/zephir-lang/zephir/issues/2397

EDIT CI pipeline for all aches https://gitlab.alpinelinux.org/alpine/aports/-/pipelines/152930

andypost avatar Feb 12 '23 14:02 andypost

Implemented in #16282

Jeckerson avatar Feb 26 '23 22:02 Jeckerson