oerdnj / deb.sury.org

Public bugreports for anything ppa:ondrej/*
800 stars 26 forks source link

Cannot build PHP 7.2 and earlier from source on Debian trixie #2138

Closed anomiex closed 1 month ago

anomiex commented 1 month ago

Frequently asked questions

Describe the bug Downloading the sources for PHP 7.2 and earlier for bookworm (via apt-get source) and attempting to compile them on a system running Debian trixie or sid fails due to the use of -Werror=implicit-function-declaration by default now.

I know you don't officially support Debian testing, but eventually it'll become stable at which point you'll probably run into this. I figure I may as well let you know ahead of time. šŸ™‚

To Reproduce Steps to reproduce the behavior:

  1. Be running Debian trixie or unstable. Using a Docker container works.
  2. Fetch and unpack the sources, install build deps, and attempt to build with dpkg-buildpackage -b -uc.

The different versions of PHP fail with different errors, but as far as I can tell the underlying cause is the same.

PHP 7.2 ``` /usr/local/src/bugfix-debs/php/php7.2/php7.2-7.2.34/main/reentrancy.c: In function 'php_readdir_r': /usr/local/src/bugfix-debs/php/php7.2/php7.2-7.2.34/main/reentrancy.c:139:9: warning: 'readdir_r' is deprecated [-Wdeprecated-declarations] 139 | readdir_r(dirp, entry); | ^~~~~~~~~ In file included from /usr/local/src/bugfix-debs/php/php7.2/php7.2-7.2.34/Zend/zend_virtual_cwd.h:78, from /usr/local/src/bugfix-debs/php/php7.2/php7.2-7.2.34/main/php.h:471, from /usr/local/src/bugfix-debs/php/php7.2/php7.2-7.2.34/main/php_reentrancy.h:24, from /usr/local/src/bugfix-debs/php/php7.2/php7.2-7.2.34/main/reentrancy.c:28: /usr/include/dirent.h:185:12: note: declared here 185 | extern int readdir_r (DIR *__restrict __dirp, | ^~~~~~~~~ /usr/local/src/bugfix-debs/php/php7.2/php7.2-7.2.34/main/reentrancy.c:139:9: error: too few arguments to function 'readdir_r' 139 | readdir_r(dirp, entry); | ^~~~~~~~~ /usr/include/dirent.h:185:12: note: declared here 185 | extern int readdir_r (DIR *__restrict __dirp, | ^~~~~~~~~ ```
PHP 7.0 and 7.1 ``` In file included from /usr/local/src/bugfix-debs/php/php7.1/php7.1-7.1.33/main/php.h:34, from /usr/local/src/bugfix-debs/php/php7.1/php7.1-7.1.33/ext/intl/dateformat/../php_intl.h:23, from /usr/local/src/bugfix-debs/php/php7.1/php7.1-7.1.33/ext/intl/dateformat/dateformat_format_object.cpp:28: /usr/local/src/bugfix-debs/php/php7.1/php7.1-7.1.33/ext-build/main/php_config.h:2575:5: error: conflicting declaration of 'int zend_sprintf(char*, const char*, ...)' with 'C' linkage 2575 | int zend_sprintf(char *buffer, const char *format, ...); | ^~~~~~~~~~~~ In file included from /usr/local/src/bugfix-debs/php/php7.1/php7.1-7.1.33/main/php_stdint.h:62, from /usr/local/src/bugfix-debs/php/php7.1/php7.1-7.1.33/Zend/../TSRM/TSRM.h:23, from /usr/local/src/bugfix-debs/php/php7.1/php7.1-7.1.33/Zend/zend_portability.h:52, from /usr/local/src/bugfix-debs/php/php7.1/php7.1-7.1.33/Zend/zend_types.h:27, from /usr/local/src/bugfix-debs/php/php7.1/php7.1-7.1.33/ext/intl/dateformat/../intl_convertcpp.h:27, from /usr/local/src/bugfix-debs/php/php7.1/php7.1-7.1.33/ext/intl/dateformat/dateformat_format_object.cpp:25: /usr/local/src/bugfix-debs/php/php7.1/php7.1-7.1.33/ext-build/main/php_config.h:2575:5: note: previous declaration with 'C++' linkage 2575 | int zend_sprintf(char *buffer, const char *format, ...); | ^~~~~~~~~~~~ ```
PHP 5.6 ``` /usr/local/src/bugfix-debs/php/php5.6/php5.6-5.6.40/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.c: In function 'mbfl_filt_conv_utf8_mobile_wchar': /usr/local/src/bugfix-debs/php/php5.6/php5.6-5.6.40/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.c:210:25: error: implicit declaration of function 'mbfl_filt_put_invalid_char' [-Werror=implicit-function-declaration] 210 | mbfl_filt_put_invalid_char(c, filter); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/local/src/bugfix-debs/php/php5.6/php5.6-5.6.40/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.c:192:23: warning: unused variable 'flag' [-Wunused-variable] 192 | int s, w = 0, flag = 0; | ^~~~ /usr/local/src/bugfix-debs/php/php5.6/php5.6-5.6.40/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.c:192:16: warning: unused variable 'w' [-Wunused-variable] 192 | int s, w = 0, flag = 0; | ^ ```

Your understanding of what is happening The use of -Werror=implicit-function-declaration causes some of the configure script checks to fail due to implicit declaration of exit. The build then tries to include fallback versions for the functions, which winds up failing for various reasons.

Additionally, for PHP 5.6, there are some missing function forward declarations.

What steps did you take to resolve issue yourself before reporting it here Applying the changes from https://github.com/php/php-src/commit/aa405b7da270595d349d0596ad31305a41d4b1c0 seems to have been enough to fix 7.0ā€“7.2.

PHP 5.6 also needed some missing forward declarations added:

Expected behavior It builds successfully.

Distribution (please complete the following information):

Package(s) (please complete the following information): N/A

Additional context Here are diffs of what worked for me, in case that helps you. php5.6-5.6.40.diff.txt php7.0-7.0.33.diff.txt php7.1-7.1.33.diff.txt php7.2-7.2.34.diff.txt

Thanks for maintaining this!

oerdnj commented 1 month ago

Thanks for the patches, but this has been already fixed in the git repo. There was no urge to upload the fixed version to bookworm though.

The php-config5.6 required some more fixing.