phalcon / cphalcon

High performance, full-stack PHP framework delivered as a C extension.
https://phalcon.io
BSD 3-Clause "New" or "Revised" License
10.79k stars 1.96k forks source link

[BUG]: broken build [-Wincompatible-pointer-types] #16531

Open remicollet opened 9 months ago

remicollet commented 9 months ago

With recent GCC 14 (on Fedora 40)

Build fails with tons of:

/builddir/build/BUILD/php83-php-phalcon5-5.6.1/phalcon-5.6.1/phalcon.zep.c: In function 'zim_Phalcon_Storage_Adapter_Weak_increment':
/opt/remi/php83/root/usr/include/php/Zend/zend_API.h:2059:58: error: passing argument 2 of 'zend_parse_arg_str' from incompatible pointer type [-Wincompatible-pointer-types]
 2059 |                 if (UNEXPECTED(!zend_parse_arg_str(_arg, &dest, check_null, _i))) { \
/opt/remi/php83/root/usr/include/php/Zend/zend_portability.h:363:52: note: in definition of macro 'UNEXPECTED'
  363 | # define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
      |                                                    ^~~~~~~~~
/opt/remi/php83/root/usr/include/php/Zend/zend_API.h:2066:9: note: in expansion of macro 'Z_PARAM_STR_EX'
 2066 |         Z_PARAM_STR_EX(dest, 0, 0)
      |         ^~~~~~~~~~~~~~
/builddir/build/BUILD/php83-php-phalcon5-5.6.1/phalcon-5.6.1/phalcon.zep.c:204823:17: note: in expansion of macro 'Z_PARAM_STR'
204823 |                 Z_PARAM_STR(key)
       |                 ^~~~~~~~~~~
/opt/remi/php83/root/usr/include/php/Zend/zend_API.h:2241:76: note: expected 'zend_string **' {aka 'struct _zend_string **'} but argument is of type 'zval *' {aka 'struct _zval_struct *'}
 2241 | static zend_always_inline bool zend_parse_arg_str(zval *arg, zend_string **dest, bool check_null, uint32_t arg_num)
      |                                                              ~~~~~~~~~~~~~~^~~~

Was already reported for a long time.

This was a warning, this in now an error

Jeckerson commented 9 months ago

Yes, I remember your report and issue is still opened - https://github.com/zephir-lang/zephir/issues/2326

There was my attempts during last months to improve it, but it is not trivial task to do. As whole Zephir relies on zval instead of specific types as zend_string or any other. But, there are already improvements in another types, such as zend_bool and zend_long. Which are located in Zephir's development branch.

I'll try to review it in near future...

remicollet commented 9 months ago

As whole Zephir relies on zval instead of specific types as zend_string or any other.

If this case, DON'T use Z_PARAM_STR Instead use Z_PARAM_ZVAL and check Z_TYPE_P(arg) == IS_STRING yourself

stfast commented 6 months ago

Fedora 40 was released a week ago and we would go along with PHP 8.3 in this release. Are there any timeline to compile phalcon with GCC 14, so we can plan system upgrade?

remicollet commented 6 months ago

@stfast notice than on Fedora, you can use my repo which provides more PHP versions and more extensions than in official repository, including phalcon, see https://rpms.remirepo.net/wizard/

stfast commented 6 months ago

Remi I admire your work, great, hard and wonderfull job you you are working, but I've allways had problems with (cycylic) package dependancies with your Remi repos on Fedora upgrades in the past. Thank you reminding me, I will try.

andypost commented 1 month ago

Any progress on the issue, I have to remove the package from Alpinelinux repo as no way to build it using GCC14

HiralRajgor commented 1 month ago

@niden

Please help us on this issue, as alpine linux package is removed from repo due to this.

Jeckerson commented 1 month ago

On it

jukuan commented 1 month ago

same issue. Any updates on it? or replacements?suggestions? A lot of people really need the phalcon package for alpine :) Thanks in advance.

Jeckerson commented 1 month ago

@andypost @jukuan How do you install in Alpine?

Jeckerson commented 1 month ago

Just tried to compile on latest version of alpine with PHP8.3 and it requires near 5Gb of RAM: image

before that it killed process with error:

cc: fatal error: Killed signal terminated program cc1

For some urgent cases: use swap files with 4-5Gb to compile it on VMs/VPS with small RAM. Guide how to create swap file - Create swap file on Linux

I'll investigate what might be possible to do, but current warnings are not the core problem is original issue.

HiralRajgor commented 1 month ago

same issue. Any updates on it? or replacements?suggestions? A lot of people really need the phalcon package for alpine :) Thanks in advance.

Yeah True, I had to work on weekend, as my prod release got delayed due to package removal lol.

But I did some alternates, it might not be the best way but anyways it saved me :

jukuan commented 1 month ago

@andypost @jukuan How do you install in Alpine?

Now I'm using docker:

ENV PHALCON_VERSION=5.8.0
WORKDIR /usr/src/php/ext
RUN set -xe && \
    curl -LO https://github.com/phalcon/cphalcon/archive/v${PHALCON_VERSION}.tar.gz && \
    tar xzf v${PHALCON_VERSION}.tar.gz && cd cphalcon-${PHALCON_VERSION}/build && ./install && \
    echo "extension=phalcon.so" > /usr/local/etc/php/conf.d/phalcon.ini && \
    cd ../.. && rm -rf v${PHALCON_VERSION}.tar.gz cphalcon-${PHALCON_VERSION}

But previously i used just the "php82-pecl-phalcon" package:

- apk add -X http://dl-cdn.alpinelinux.org/alpine/edge/testing php82-pecl-phalcon=5.8.0-r0

and that way stopped working last 3-4 days, because package has been removed by vendor.

jukuan commented 1 month ago

My solution is to build the Phalcon from the source code for my alpine container. The basic Dockerfile snippes is below. Don't rely on the testing repositories any more :)

Feel free to use it and/or tell me what might be improved.

FROM php:8.2-cli-alpine

ARG PHALCON_VER=5.8.0

RUN set -eux; \
    cd /tmp && \
    curl -sSJL -o phalcon.tar.gz "https://github.com/phalcon/cphalcon/archive/v${PHALCON_VER}.tar.gz" && \
    mkdir -p /usr/src/phalcon && \
    tar -xzf phalcon.tar.gz -C /usr/src/phalcon --strip-components=1 && \
    cd /usr/src/phalcon/build && ./install && \
    docker-php-ext-enable decimal phalcon  && \
    \
# Clean up
    apk del \
        autoconf \
        gcc \
        g++ \
        git \
        libaio \
        libc-dev \
        make \
        pkgconf \
        re2c \
    && rm -rf /var/cache/apk/* /tmp/*

COPY --from=composer:2.8 /usr/bin/composer /usr/local/bin/composer

WORKDIR /var/www/html
CMD ["php", "-a"]