Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phps: Fix build with GCC 14 #393

Merged
merged 4 commits into from
Jan 25, 2025
Merged

phps: Fix build with GCC 14 #393

merged 4 commits into from
Jan 25, 2025

Conversation

jtojnar
Copy link
Member

@jtojnar jtojnar commented Jan 23, 2025

No description provided.

@jtojnar jtojnar force-pushed the bump branch 2 times, most recently from e5d912b to 1f99b72 Compare January 23, 2025 09:32
@drupol
Copy link
Collaborator

drupol commented Jan 23, 2025

Current issue:

       > /nix/store/4fvc5fm8bszmkydng1ivrvr5cbvr1g60-bash-5.2p37/bin/bash /build/php-7.0.33/libtool --silent --preserve-dup-deps --mode=compile gcc  -Iext/hash/ -I/build/php-7.0.33/ext/hash/ -DPHP_ATOM_INC -I/build/php-7.0.33/include -I/build/php-7.0.33/main -I/build/php-7.0.33 -I/nix/store/vvjw3qra3bq198alp4wfbx52g46hvh0b-systemd-257.2-dev/include -I/build/php-7.0.33/ext/date/lib -I/nix/store/jjwjnbfqip6fbaii1czrfcfp6cg1s90f-libxml2-2.12.9-dev/include/libxml2 -I/nix/store/s99hv8mcyrkxznz4ljgnmbc9r12zwzgl-pcre-8.45-dev/include -I/build/php-7.0.33/TSRM -I/build/php-7.0.33/Zend    -g -O2 -fvisibility=hidden   -c /build/php-7.0.33/ext/hash/hash.c -o ext/hash/hash.lo
       > /build/php-7.0.33/ext/libxml/libxml.c: In function 'zif_libxml_use_internal_errors':
       > /build/php-7.0.33/ext/libxml/libxml.c:995:49: error: passing argument 2 of 'xmlSetStructuredErrorFunc' from incompatible pointer type []
       >   995 |                 xmlSetStructuredErrorFunc(NULL, php_libxml_structured_error_handler);
       >       |                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       >       |                                                 |
       >       |                                                 void (*)(void *, xmlError *) {aka void (*)(void *, struct _xmlError *)}
       > In file included from /nix/store/jjwjnbfqip6fbaii1czrfcfp6cg1s90f-libxml2-2.12.9-dev/include/libxml2/libxml/valid.h:15,
       >                  from /nix/store/jjwjnbfqip6fbaii1czrfcfp6cg1s90f-libxml2-2.12.9-dev/include/libxml2/libxml/parser.h:19,
       >                  from /build/php-7.0.33/ext/libxml/libxml.c:39:
       > /nix/store/jjwjnbfqip6fbaii1czrfcfp6cg1s90f-libxml2-2.12.9-dev/include/libxml2/libxml/xmlerror.h:898:57: note: expected 'xmlStructuredErrorFunc' {aka 'void (*)(void *, const struct _xmlError *)'} but argument is of type 'void (*)(void *, xmlError *)' {aka 'void (*)(void *, struct _xmlError *)'}
       >   898 |                                  xmlStructuredErrorFunc handler);
       >       |                                  ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
       > /build/php-7.0.33/ext/libxml/libxml.c: In function 'zif_libxml_get_last_error':
       > /build/php-7.0.33/ext/libxml/libxml.c:1011:15: warning: assignment discards 'const' qualifier from pointer target type []
       >  1011 |         error = xmlGetLastError();
       >       |               ^
       > At top level:
       > cc1: note: unrecognized command-line option '-Wno-incompatible-pointer-types-discards-qualifiers' may have been intended to silence earlier diagnostics
       > cc1: note: unrecognized command-line option '-Wno-incompatible-function-pointer-types' may have been intended to silence earlier diagnostics
       > cc1: note: unrecognized command-line option '-Wno-implicit-const-int-float-conversion' may have been intended to silence earlier diagnostics
       > make: *** [Makefile:668: ext/libxml/libxml.lo] Error 1
       > make: *** Waiting for unfinished jobs....
       For full logs, run 'nix log /nix/store/djfcsdm9hayg8k52j49xbs4gfv3f6fmd-php-7.0.33.drv'.
error (ignored): error: cannot unlink '"/tmp/nix-build-openssl-1.1.1w.drv-0/build/openssl-1.1.1w"': Directory not empty
error: 1 dependencies of derivation '/nix/store/lbhqb1aslj0hv6ihh1r5wii6yycqgamb-php-with-extensions-7.0.33.drv' failed to build

@jtojnar
Copy link
Member Author

jtojnar commented Jan 23, 2025

Maybe it is necessary to switch from -Wno- to -Wno-error=:

According to https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Werror:

  • -Werror
    Make all warnings into errors.
  • -Werror=
    Make the specified warning into an error. The specifier for a warning is appended; for example -Werror=switch turns the warnings controlled by -Wswitch into errors. This switch takes a negative form, to be used to negate -Werror for specific warnings; for example -Wno-error=switch makes -Wswitch warnings not be errors, even when -Werror is in effect.

@drupol
Copy link
Collaborator

drupol commented Jan 23, 2025

IMO, I think we should not spend too much time on this and use the most simple and straightforward solution to fix these old and unmaintained PHP versions.
If you believe that changing that flag might fix the issue, then let's go for it and move on!

Concatenate all the flags from array and also move to `env` attribute.
@jtojnar jtojnar marked this pull request as ready for review January 23, 2025 23:56
GCC 14 has gotten stricter as well.
@jtojnar jtojnar force-pushed the bump branch 2 times, most recently from 14bceda to ee4c32e Compare January 24, 2025 00:37
@jtojnar
Copy link
Member Author

jtojnar commented Jan 24, 2025

Looks like it now mostly builds. The only remaining thing as far as I can see is the need to rebase the gettext patch for PHP 7.1 through 7.4.

@drupol

This comment was marked as outdated.

@jtojnar
Copy link
Member Author

jtojnar commented Jan 25, 2025

I would expect it needs to include the C code changes since per the commit message, it will crash.

@drupol
Copy link
Collaborator

drupol commented Jan 25, 2025

Oh... I wonder if such a patch already exist in another similar project aiming at maintaining old PHP versions. Do you know any of them?

@jtojnar
Copy link
Member Author

jtojnar commented Jan 25, 2025

The only thing I am aware of is https://github.com/shivammathur/setup-php and it does not appear to have any specific gettext patches in either homebrew repository. Searching GitHub does not reveal anything. It is possible no-one else is actually running gettext tests on Darwin.

Do we even want to fix that? It might be pretty rare for projects to ① run old version of PHP ② on Darwin ③ using dgettext ④ with LC_ALL argument. I was only able to find a single repo on GitHub doing that. If not we could just skip the tests and let such cases crash.

@drupol
Copy link
Collaborator

drupol commented Jan 25, 2025

I totally agree. Let's remove the failing test.

…th gettext 0.22.5

The incoming bump of the gettext library to 0.22.5 reportedly [1] introduces an assertion that `category` argument of `dcgettext` and `dcngettext` functions is not `LC_ALL`, causing PHP crash with SIGABRT when that happens.  This should be rare in practice – I only found one example of a decade-old WordPress plug-in doing that [2].  However, one test was passing `0` as the category argument to those functions, which triggered the assertion on Darwin because it defines `LC_ALL` as 0. On Linux, glibc defines `LC_CTYPE` as 0 so it is not problem there.

PHP 8.2 introduced a validation step [1] that will make the functions throw on receiving `LC_ALL`, and we cherry-picked it to 8.0.
We decided just to remove the offending test on older versions since the crash is unlikely in practice and backporting the fix is too much bother.

[1]: php/php-src@9999a0c
[2]: https://github.com/search?utf8=%E2%9C%93&q=%2Fdcn%3Fgettext.%2B%28LC_ALL%7C0%29%2F+language%3APHP&type=code
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/4989a246d7a390a859852baddb1013f825435cee' (2024-12-17)
  → 'github:NixOS/nixpkgs/5757bbb8bd7c0630a0cc4bb19c47e588db30b97c' (2025-01-22)
@jtojnar
Copy link
Member Author

jtojnar commented Jan 25, 2025

Split it into a separate commit.

@drupol drupol merged commit c59f808 into master Jan 25, 2025
35 checks passed
@drupol drupol deleted the bump branch January 25, 2025 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants