dstogov / php-ffi

PHP Foreign Function Interface
570 stars 32 forks source link

make fail, ZEND_ACC_PRELOADED not found #21

Open yanggs07 opened 5 years ago

yanggs07 commented 5 years ago
ygs@proxy:~/php-ffi$ make
/bin/bash /home/ygs/php-ffi/libtool --mode=compile cc  -I. -I/home/ygs/php-ffi -DPHP_ATOM_INC -I/home/ygs/php-ffi/include -I/home/ygs/php-ffi/main -I/home/ygs/php-ffi -I/usr/include/php/20180731 -I/usr/include/php/20180731/main -I/usr/include/php/20180731/TSRM -I/usr/include/php/20180731/Zend -I/usr/include/php/20180731/ext -I/usr/include/php/20180731/ext/date/lib  -DHAVE_CONFIG_H  -g
-O2   -c /home/ygs/php-ffi/ffi.c -o ffi.lo
libtool: compile:  cc -I. -I/home/ygs/php-ffi -DPHP_ATOM_INC -I/home/ygs/php-ffi/include -I/home/ygs/php-ffi/main -I/home/ygs/php-ffi -I/usr/include/php/20180731 -I/usr/include/php/20180731/main -I/usr/include/php/20180731/TSRM -I/usr/include/php/20180731/Zend -I/usr/include/php/20180731/ext -I/usr/include/php/20180731/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /home/ygs/php-ffi/ffi.c  -fPIC -DPIC -o .libs/ffi.o
/home/ygs/php-ffi/ffi.c: In function ‘zend_ffi_validate_api_restriction’:
/home/ygs/php-ffi/ffi.c:2530:66: error: ‘ZEND_ACC_PRELOADED’ undeclared (first use in this function); did you mean ‘ZEND_FFI_PRELOAD’?
     && (execute_data->prev_execute_data->func->common.fn_flags & ZEND_ACC_PRELOADED))
                                                                  ^~~~~~~~~~~~~~~~~~
                                                                  ZEND_FFI_PRELOAD
/home/ygs/php-ffi/ffi.c:2530:66: note: each undeclared identifier is reported only once for each
function it appears in
/home/ygs/php-ffi/ffi.c:2531:31: error: ‘ZEND_COMPILE_PRELOAD’ undeclared (first use in this function); did you mean ‘ZEND_FFI_PRELOAD’?
    || (CG(compiler_options) & ZEND_COMPILE_PRELOAD)) {
                               ^~~~~~~~~~~~~~~~~~~~
                               ZEND_FFI_PRELOAD
/home/ygs/php-ffi/ffi.c: In function ‘zim_FFI_load’:
/home/ygs/php-ffi/ffi.c:2819:46: error: ‘ZEND_COMPILE_PRELOAD’ undeclared (first use in this function); did you mean ‘ZEND_FFI_PRELOAD’?
  zend_bool preload = (CG(compiler_options) & ZEND_COMPILE_PRELOAD) != 0;
                                              ^~~~~~~~~~~~~~~~~~~~
                                              ZEND_FFI_PRELOAD
In file included from /usr/include/php/20180731/Zend/zend.h:29:0,
                 from /usr/include/php/20180731/main/php.h:34,
                 from /home/ygs/php-ffi/ffi.c:23:
/home/ygs/php-ffi/ffi.c: In function ‘zim_FFI_free’:
/home/ygs/php-ffi/ffi.c:3411:76: warning: implicit declaration of function ‘is_zend_ptr’; did you mean ‘is_zend_mm’? [-Wimplicit-function-declaration]
    pefree(cdata->ptr_holder, (cdata->flags & ZEND_FFI_FLAG_PERSISTENT) || !is_zend_ptr(cdata->ptr_holder));
                                                                            ^
/usr/include/php/20180731/Zend/zend_alloc.h:195:36: note: in definition of macro ‘pefree’
 #define pefree(ptr, persistent)  ((persistent)?free(ptr):efree(ptr))
                                    ^~~~~~~~~~
Makefile:194: recipe for target 'ffi.lo' failed
make: *** [ffi.lo] Error 1
yanggs07 commented 5 years ago

Env: ubuntu18.04+php7.3 with libffi-dev 3.2.1-8 amd64 with the patch https://github.com/fpoirotte/php-ffi/commit/734630fe3d2e3efd343d3f3636b58446abd9c941.diff to pass the configure

fpoirotte commented 5 years ago

Commit 86b43c3519b9803aa7074f23d936f50e50b1b5ee introduced the notion of API restrictions. These restrictions are based on the new preload RFC that has recently been added to PHP's master branch (see https://wiki.php.net/rfc/preload & php/php-src@f6d227ed4f5d4c0276eb720806e808baceb37f10). Unfortunately, this means that PHP must have been compiled from a nightly snapshot / fresh clone;

Keep in mind that this extension is still pretty new: the API may still change (see recent commits related to FFI:cdef, FFI::typeof, FFI::arrayType and so on).

dstogov commented 5 years ago

@yanggs07 @fpoirotte this extension is going to be part of PHP 7.4 (7.3 is not supported, however it might be possible to make it compatible)