Skip to content

Extension does not compile with php 8 #10

Closed
@cleboo

Description

@cleboo

Hi!

I recently tried to install php-ext-jq in a docker container (base image: php:8). During make with php 8 I get the following error:

/php-ext-jq_build/php-ext-jq/jq.c: In function 'php_jq_err_cb':
/php-ext-jq_build/php-ext-jq/jq.c:95:5: warning: implicit declaration of function 'TSRMLS_FETCH'; did you mean 'TSRMLS_CACHE'? [-Wimplicit-function-declaration]
     TSRMLS_FETCH();
     ^~~~~~~~~~~~
     TSRMLS_CACHE
In file included from /php-ext-jq_build/php-ext-jq/jq.c:11:
/php-ext-jq_build/php-ext-jq/php_jq.h:31:50: error: expected ')' before 'TSRMLS_CC'
 #define PHP_JQ_ERR(e, ...) php_error_docref(NULL TSRMLS_CC, e, __VA_ARGS__)
                                                  ^~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:99:13: note: in expansion of macro 'PHP_JQ_ERR'
             PHP_JQ_ERR(E_WARNING, jv_string_value(dump));
             ^~~~~~~~~~
/php-ext-jq_build/php-ext-jq/php_jq.h:31:28: error: too few arguments to function 'php_error_docref'
 #define PHP_JQ_ERR(e, ...) php_error_docref(NULL TSRMLS_CC, e, __VA_ARGS__)
                            ^~~~~~~~~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:99:13: note: in expansion of macro 'PHP_JQ_ERR'
             PHP_JQ_ERR(E_WARNING, jv_string_value(dump));
             ^~~~~~~~~~
In file included from /php-ext-jq_build/php-ext-jq/jq.c:5:
/usr/local/include/php/main/php.h:341:23: note: declared here
 PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format, ...)
                       ^~~~~~~~~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c: In function 'zim_Jq___construct':
/php-ext-jq_build/php-ext-jq/jq.c:43:41: error: expected ')' before 'TSRMLS_CC'
     zend_throw_exception_ex(NULL, _code TSRMLS_CC, __VA_ARGS__)
                                         ^~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:131:9: note: in expansion of macro 'PHP_JQ_EXCEPTION'
         PHP_JQ_EXCEPTION(0, "jq object has not been correctly initialized "
         ^~~~~~~~~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:43:5: error: too few arguments to function 'zend_throw_exception_ex'
     zend_throw_exception_ex(NULL, _code TSRMLS_CC, __VA_ARGS__)
     ^~~~~~~~~~~~~~~~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:131:9: note: in expansion of macro 'PHP_JQ_EXCEPTION'
         PHP_JQ_EXCEPTION(0, "jq object has not been correctly initialized "
         ^~~~~~~~~~~~~~~~
In file included from /php-ext-jq_build/php-ext-jq/jq.c:9:
/usr/local/include/php/Zend/zend_exceptions.h:61:33: note: declared here
 ZEND_API ZEND_COLD zend_object *zend_throw_exception_ex(zend_class_entry *exception_ce, zend_long code, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 3, 4);
                                 ^~~~~~~~~~~~~~~~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c: In function 'zim_Jq_load':
/php-ext-jq_build/php-ext-jq/jq.c:147:47: error: expected ')' before 'TSRMLS_CC'
     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
                                               ^~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:147:9: error: too few arguments to function 'zend_parse_parameters'
     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
         ^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/php/main/php.h:35,
                 from /php-ext-jq_build/php-ext-jq/jq.c:5:
/usr/local/include/php/Zend/zend_API.h:304:22: note: declared here
 ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec, ...);
                      ^~~~~~~~~~~~~~~~~~~~~
In file included from /php-ext-jq_build/php-ext-jq/jq.c:11:
/php-ext-jq_build/php-ext-jq/php_jq.h:31:50: error: expected ')' before 'TSRMLS_CC'
 #define PHP_JQ_ERR(e, ...) php_error_docref(NULL TSRMLS_CC, e, __VA_ARGS__)
                                                  ^~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:167:13: note: in expansion of macro 'PHP_JQ_ERR'
             PHP_JQ_ERR(E_WARNING, "load json parse error");
             ^~~~~~~~~~
/php-ext-jq_build/php-ext-jq/php_jq.h:31:28: error: too few arguments to function 'php_error_docref'
 #define PHP_JQ_ERR(e, ...) php_error_docref(NULL TSRMLS_CC, e, __VA_ARGS__)
                            ^~~~~~~~~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:167:13: note: in expansion of macro 'PHP_JQ_ERR'
             PHP_JQ_ERR(E_WARNING, "load json parse error");
             ^~~~~~~~~~
In file included from /php-ext-jq_build/php-ext-jq/jq.c:5:
/usr/local/include/php/main/php.h:341:23: note: declared here
 PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format, ...)
                       ^~~~~~~~~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c: In function 'zim_Jq_loadFile':
/php-ext-jq_build/php-ext-jq/jq.c:192:47: error: expected ')' before 'TSRMLS_CC'
     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
                                               ^~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:192:9: error: too few arguments to function 'zend_parse_parameters'
     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",
         ^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/php/main/php.h:35,
                 from /php-ext-jq_build/php-ext-jq/jq.c:5:
/usr/local/include/php/Zend/zend_API.h:304:22: note: declared here
 ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec, ...);
                      ^~~~~~~~~~~~~~~~~~~~~
In file included from /php-ext-jq_build/php-ext-jq/jq.c:11:
/php-ext-jq_build/php-ext-jq/php_jq.h:31:50: error: expected ')' before 'TSRMLS_CC'
 #define PHP_JQ_ERR(e, ...) php_error_docref(NULL TSRMLS_CC, e, __VA_ARGS__)
                                                  ^~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:226:21: note: in expansion of macro 'PHP_JQ_ERR'
                     PHP_JQ_ERR(E_WARNING, "load json parse error");
                     ^~~~~~~~~~
/php-ext-jq_build/php-ext-jq/php_jq.h:31:28: error: too few arguments to function 'php_error_docref'
 #define PHP_JQ_ERR(e, ...) php_error_docref(NULL TSRMLS_CC, e, __VA_ARGS__)
                            ^~~~~~~~~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:226:21: note: in expansion of macro 'PHP_JQ_ERR'
                     PHP_JQ_ERR(E_WARNING, "load json parse error");
                     ^~~~~~~~~~
In file included from /php-ext-jq_build/php-ext-jq/jq.c:5:
/usr/local/include/php/main/php.h:341:23: note: declared here
 PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format, ...)
                       ^~~~~~~~~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c: At top level:
/php-ext-jq_build/php-ext-jq/jq.c:263:51: error: expected ';', ',' or ')' before 'TSRMLS_DC'
 static void php_jv_dump(zval **return_value, jv x TSRMLS_DC);
                                                   ^~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:265:39: error: expected ';', ',' or ')' before 'TSRMLS_DC'
 php_jv_dump(zval **return_value, jv x TSRMLS_DC)
                                       ^~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:423:69: error: expected ';', ',' or ')' before 'TSRMLS_DC'
 php_jq_filter(zval **return_value, jq_state *jq, jv json, int flags TSRMLS_DC)
                                                                     ^~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c: In function 'zim_Jq_filter':
/php-ext-jq_build/php-ext-jq/jq.c:524:47: error: expected ')' before 'TSRMLS_CC'
     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l",
                                               ^~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:524:9: error: too few arguments to function 'zend_parse_parameters'
     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l",
         ^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/php/main/php.h:35,
                 from /php-ext-jq_build/php-ext-jq/jq.c:5:
/usr/local/include/php/Zend/zend_API.h:304:22: note: declared here
 ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec, ...);
                      ^~~~~~~~~~~~~~~~~~~~~
In file included from /php-ext-jq_build/php-ext-jq/jq.c:11:
/php-ext-jq_build/php-ext-jq/php_jq.h:31:50: error: expected ')' before 'TSRMLS_CC'
 #define PHP_JQ_ERR(e, ...) php_error_docref(NULL TSRMLS_CC, e, __VA_ARGS__)
                                                  ^~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:537:13: note: in expansion of macro 'PHP_JQ_ERR'
             PHP_JQ_ERR(E_WARNING, "undefined load json");
             ^~~~~~~~~~
/php-ext-jq_build/php-ext-jq/php_jq.h:31:28: error: too few arguments to function 'php_error_docref'
 #define PHP_JQ_ERR(e, ...) php_error_docref(NULL TSRMLS_CC, e, __VA_ARGS__)
                            ^~~~~~~~~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:537:13: note: in expansion of macro 'PHP_JQ_ERR'
             PHP_JQ_ERR(E_WARNING, "undefined load json");
             ^~~~~~~~~~
In file included from /php-ext-jq_build/php-ext-jq/jq.c:5:
/usr/local/include/php/main/php.h:341:23: note: declared here
 PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format, ...)
                       ^~~~~~~~~~~~~~~~
In file included from /php-ext-jq_build/php-ext-jq/jq.c:11:
/php-ext-jq_build/php-ext-jq/php_jq.h:31:50: error: expected ')' before 'TSRMLS_CC'
 #define PHP_JQ_ERR(e, ...) php_error_docref(NULL TSRMLS_CC, e, __VA_ARGS__)
                                                  ^~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:546:13: note: in expansion of macro 'PHP_JQ_ERR'
             PHP_JQ_ERR(E_WARNING, "filter compile error");
             ^~~~~~~~~~
/php-ext-jq_build/php-ext-jq/php_jq.h:31:28: error: too few arguments to function 'php_error_docref'
 #define PHP_JQ_ERR(e, ...) php_error_docref(NULL TSRMLS_CC, e, __VA_ARGS__)
                            ^~~~~~~~~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:546:13: note: in expansion of macro 'PHP_JQ_ERR'
             PHP_JQ_ERR(E_WARNING, "filter compile error");
             ^~~~~~~~~~
In file included from /php-ext-jq_build/php-ext-jq/jq.c:5:
/usr/local/include/php/main/php.h:341:23: note: declared here
 PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format, ...)
                       ^~~~~~~~~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:551:5: warning: implicit declaration of function 'php_jq_filter'; did you mean 'zim_Jq_filter'? [-Wimplicit-function-declaration]
     php_jq_filter(&return_value, intern->jq, intern->json, flags TSRMLS_CC);
     ^~~~~~~~~~~~~
     zim_Jq_filter
/php-ext-jq_build/php-ext-jq/jq.c:551:65: error: expected ')' before 'TSRMLS_CC'
     php_jq_filter(&return_value, intern->jq, intern->json, flags TSRMLS_CC);
                                                                 ^~~~~~~~~~
                                                                 )
/php-ext-jq_build/php-ext-jq/jq.c: At top level:
/php-ext-jq_build/php-ext-jq/jq.c:557:24: error: expected ';', ',' or ')' before 'TSRMLS_DC'
             long flags TSRMLS_DC)
                        ^~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c: In function 'zim_Jq_parse':
/php-ext-jq_build/php-ext-jq/jq.c:609:47: error: expected ')' before 'TSRMLS_CC'
     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l",
                                               ^~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:609:9: error: too few arguments to function 'zend_parse_parameters'
     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l",
         ^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/php/main/php.h:35,
                 from /php-ext-jq_build/php-ext-jq/jq.c:5:
/usr/local/include/php/Zend/zend_API.h:304:22: note: declared here
 ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec, ...);
                      ^~~~~~~~~~~~~~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:619:5: warning: implicit declaration of function 'php_jq_exec'; did you mean 'php_jq_init'? [-Wimplicit-function-declaration]
     php_jq_exec(&return_value, str, str_len,
     ^~~~~~~~~~~
     php_jq_init
/php-ext-jq_build/php-ext-jq/jq.c:620:42: error: expected ')' before 'TSRMLS_CC'
                 filter, filter_len, flags TSRMLS_CC);
                                          ^~~~~~~~~~
                                          )
/php-ext-jq_build/php-ext-jq/jq.c: In function 'zim_Jq_parseFile':
/php-ext-jq_build/php-ext-jq/jq.c:639:47: error: expected ')' before 'TSRMLS_CC'
     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l",
                                               ^~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:639:9: error: too few arguments to function 'zend_parse_parameters'
     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l",
         ^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/php/main/php.h:35,
                 from /php-ext-jq_build/php-ext-jq/jq.c:5:
/usr/local/include/php/Zend/zend_API.h:304:22: note: declared here
 ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec, ...);
                      ^~~~~~~~~~~~~~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:661:50: error: expected ')' before 'TSRMLS_CC'
                         filter, filter_len, flags TSRMLS_CC);
                                                  ^~~~~~~~~~
                                                  )
/php-ext-jq_build/php-ext-jq/jq.c: At top level:
/php-ext-jq_build/php-ext-jq/jq.c:722:52: error: expected ';', ',' or ')' before 'TSRMLS_DC'
 php_jq_new_ex(zend_class_entry *ce, php_jq_t **ptr TSRMLS_DC)
                                                    ^~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:744:33: error: expected ';', ',' or ')' before 'TSRMLS_DC'
 php_jq_new(zend_class_entry *ce TSRMLS_DC)
                                 ^~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c: In function 'zm_startup_jq':
/php-ext-jq_build/php-ext-jq/jq.c:826:24: error: 'php_jq_new' undeclared (first use in this function); did you mean 'php_jq_ce'?
     ce.create_object = php_jq_new;
                        ^~~~~~~~~~
                        php_jq_ce
/php-ext-jq_build/php-ext-jq/jq.c:826:24: note: each undeclared identifier is reported only once for each function it appears in
/php-ext-jq_build/php-ext-jq/jq.c:828:49: error: expected ')' before 'TSRMLS_CC'
     php_jq_ce = zend_register_internal_class(&ce TSRMLS_CC);
                                                 ^~~~~~~~~~
                                                 )
/php-ext-jq_build/php-ext-jq/jq.c:41:46: error: expected ')' before 'TSRMLS_CC'
         php_jq_ce, ZEND_STRS(#name)-1, value TSRMLS_CC)
                                              ^~~~~~~~~
/php-ext-jq_build/php-ext-jq/jq.c:844:5: note: in expansion of macro 'PHP_JQ_CONST_LONG'
     PHP_JQ_CONST_LONG(RAW, JQ_OPT_RAW);
     ^~~~~~~~~~~~~~~~~

Apparently the TSRMLS_CC macro was removed from the extension interface:

Downgrading to php 7.3 solves the problem.

To reproduce you can use the following Dockerfile:

FROM php:8

RUN apt-get update \
    && apt-get -y --no-install-recommends install build-essential libjq1 git flex bison

RUN git clone --depth=1 https://github.com/kjdev/php-ext-jq.git \
    && cd php-ext-jq \
    && phpize \
    && ./configure \
    && make \
    && make test \
    && make install

Are you planning to make php-ext-jq compatible with php 8?

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions