From fa088a9477b35d8e36c8204c35fc574eaffe0190 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski <2151333+piotrkwiecinski@users.noreply.github.com> Date: Fri, 9 Aug 2024 14:19:35 +0200 Subject: [PATCH] php81: libxml2 2.13 compatibility --- pkgs/development/interpreters/php/8.1.nix | 18 +++- ...php81-fix-libxml2-2.13-compatibility.patch | 28 ++++++ pkgs/top-level/php-packages.nix | 86 +++++++++++++++++-- 3 files changed, 126 insertions(+), 6 deletions(-) create mode 100644 pkgs/development/interpreters/php/php81-fix-libxml2-2.13-compatibility.patch diff --git a/pkgs/development/interpreters/php/8.1.nix b/pkgs/development/interpreters/php/8.1.nix index 4b53f9e6c84b3..204bf316e8425 100644 --- a/pkgs/development/interpreters/php/8.1.nix +++ b/pkgs/development/interpreters/php/8.1.nix @@ -5,12 +5,28 @@ let version = "8.1.29"; hash = "sha256-h6YDEyY/L1M/GA5xknLKXkfNmITU7DyTcgGY6v+uCCc="; extraPatches = [ - # Fix build with libxml 2.12+. + # Fix build with libxml2 2.12+. # Patch from https://github.com/php/php-src/commit/0a39890c967aa57225bb6bdf4821aff7a3a3c082 (fetchpatch { url = "https://github.com/php/php-src/commit/0a39890c967aa57225bb6bdf4821aff7a3a3c082.patch"; hash = "sha256-HvpTL7aXO9gr4glFdhqUWQPrG8TYTlvbNINq33M3zS0="; }) + # Fix tests with libxml2 2.12 + (fetchpatch { + url = "https://github.com/php/php-src/commit/061058a9b1bbd90d27d97d79aebcf2b5029767b0.patch"; + hash = "sha256-0hOlAG+pOYp/gUU0MUMZvzWpgr0ncJi5GB8IeNxxyEU="; + excludes = [ + "NEWS" + ]; + }) + # Backport of PHP_LIBXML_IGNORE_DEPRECATIONS_START and PHP_LIBXML_IGNORE_DEPRECATIONS_END + # Required for libxml2 2.13 compatibility patch. + ./php81-fix-libxml2-2.13-compatibility.patch + # Fix build with libxml2 2.13+. Has to be applied after libxml2 2.12 patch. + (fetchpatch { + url = "https://github.com/php/php-src/commit/9b4f6b09d58a4e54ee60443bf9a8b166852c03e0.patch"; + hash = "sha256-YC3I0BQi3o3+VmRu/UqpqPpaSC+ekPqzbORTHftbPvY="; + }) ]; }); in diff --git a/pkgs/development/interpreters/php/php81-fix-libxml2-2.13-compatibility.patch b/pkgs/development/interpreters/php/php81-fix-libxml2-2.13-compatibility.patch new file mode 100644 index 0000000000000..b4624676ee29d --- /dev/null +++ b/pkgs/development/interpreters/php/php81-fix-libxml2-2.13-compatibility.patch @@ -0,0 +1,28 @@ +diff --git a/ext/libxml/php_libxml.h b/ext/libxml/php_libxml.h +index a1011f0b17..7a7622c482 100644 +--- a/ext/libxml/php_libxml.h ++++ b/ext/libxml/php_libxml.h +@@ -119,6 +119,23 @@ PHP_LIBXML_API void php_libxml_shutdown(void); + ZEND_TSRMLS_CACHE_EXTERN() + #endif + ++#if defined(__clang__) ++# define PHP_LIBXML_IGNORE_DEPRECATIONS_START \ ++ _Pragma("clang diagnostic push") \ ++ _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") ++# define PHP_LIBXML_IGNORE_DEPRECATIONS_END \ ++ _Pragma("clang diagnostic pop") ++#elif defined(__GNUC__) ++# define PHP_LIBXML_IGNORE_DEPRECATIONS_START \ ++ _Pragma("GCC diagnostic push") \ ++ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") ++# define PHP_LIBXML_IGNORE_DEPRECATIONS_END \ ++ _Pragma("GCC diagnostic pop") ++#else ++# define PHP_LIBXML_IGNORE_DEPRECATIONS_START ++# define PHP_LIBXML_IGNORE_DEPRECATIONS_END ++#endif ++ + /* Other extension may override the global state options, these global options + * are copied initially to ctxt->options. Set the options to a known good value. + * See libxml2 globals.c and parserInternals.c. diff --git a/pkgs/top-level/php-packages.nix b/pkgs/top-level/php-packages.nix index de9b83df972e8..4768a21ac1fe8 100644 --- a/pkgs/top-level/php-packages.nix +++ b/pkgs/top-level/php-packages.nix @@ -383,7 +383,7 @@ in { "--enable-dom" ]; # Add a PHP lower version bound constraint to avoid applying the patch on older PHP versions. - patches = lib.optionals ((lib.versions.majorMinor php.version == "8.2" && lib.versionOlder php.version "8.2.14" && lib.versionAtLeast php.version "8.2.7") || (lib.versions.majorMinor php.version == "8.1" && lib.versionAtLeast php.version "8.1.27")) [ + patches = lib.optionals ((lib.versions.majorMinor php.version == "8.2" && lib.versionOlder php.version "8.2.14" && lib.versionAtLeast php.version "8.2.7") || (lib.versions.majorMinor php.version == "8.1")) [ # Fix tests with libxml 2.12 # Part of 8.3.1RC1+, 8.2.14RC1+ (fetchpatch { @@ -393,6 +393,14 @@ in { "NEWS" ]; }) + ] ++ lib.optionals (lib.versions.majorMinor php.version == "8.1") [ + # Backport of PHP_LIBXML_IGNORE_DEPRECATIONS_START and PHP_LIBXML_IGNORE_DEPRECATIONS_END + ../development/interpreters/php/php81-fix-libxml2-2.13-compatibility.patch + # Fix build with libxml2 2.13+. Has to be applied after libxml2 2.12 patch. + (fetchpatch { + url = "https://github.com/php/php-src/commit/9b4f6b09d58a4e54ee60443bf9a8b166852c03e0.patch"; + hash = "sha256-YC3I0BQi3o3+VmRu/UqpqPpaSC+ekPqzbORTHftbPvY="; + }) ] ++ lib.optionals (lib.versions.majorMinor php.version == "8.2" && lib.versionOlder php.version "8.2.22") [ # Fixes compatibility with libxml2 2.13. Part of 8.3.10RC1+, 8.2.22RC1+ (fetchpatch { @@ -617,7 +625,24 @@ in { configureFlags = [ "--enable-simplexml" ]; - patches = lib.optionals (lib.versions.majorMinor php.version == "8.2" && lib.versionOlder php.version "8.2.22") [ + patches = lib.optionals (lib.versions.majorMinor php.version == "8.1") [ + # Fix tests with libxml2 2.12 + (fetchpatch { + url = "https://github.com/php/php-src/commit/061058a9b1bbd90d27d97d79aebcf2b5029767b0.patch"; + hash = "sha256-0hOlAG+pOYp/gUU0MUMZvzWpgr0ncJi5GB8IeNxxyEU="; + excludes = [ + "NEWS" + ]; + }) + # Backport of PHP_LIBXML_IGNORE_DEPRECATIONS_START and PHP_LIBXML_IGNORE_DEPRECATIONS_END + # Required for libxml2 2.13 compatibility patch. + ../development/interpreters/php/php81-fix-libxml2-2.13-compatibility.patch + # Fix build with libxml2 2.13+. Has to be applied after libxml2 2.12 patch. + (fetchpatch { + url = "https://github.com/php/php-src/commit/9b4f6b09d58a4e54ee60443bf9a8b166852c03e0.patch"; + hash = "sha256-YC3I0BQi3o3+VmRu/UqpqPpaSC+ekPqzbORTHftbPvY="; + }) + ] ++ lib.optionals (lib.versions.majorMinor php.version == "8.2" && lib.versionOlder php.version "8.2.22") [ # Fixes compatibility with libxml2 2.13. Part of 8.3.10RC1+, 8.2.22RC1+ (fetchpatch { url = "https://github.com/php/php-src/commit/4fe821311cafb18ca8bdf20b9d796c48a13ba552.diff?full_index=1"; @@ -647,7 +672,24 @@ in { ]; doCheck = stdenv.isDarwin; # TODO: a couple tests still fail on *-linux internalDeps = [ php.extensions.session ]; - patches = lib.optionals (lib.versions.majorMinor php.version == "8.2" && lib.versionOlder php.version "8.2.22") [ + patches = lib.optionals (lib.versions.majorMinor php.version == "8.1") [ + # Fix tests with libxml2 2.12 + (fetchpatch { + url = "https://github.com/php/php-src/commit/061058a9b1bbd90d27d97d79aebcf2b5029767b0.patch"; + hash = "sha256-0hOlAG+pOYp/gUU0MUMZvzWpgr0ncJi5GB8IeNxxyEU="; + excludes = [ + "NEWS" + ]; + }) + # Backport of PHP_LIBXML_IGNORE_DEPRECATIONS_START and PHP_LIBXML_IGNORE_DEPRECATIONS_END + # Required for libxml2 2.13 compatibility patch. + ../development/interpreters/php/php81-fix-libxml2-2.13-compatibility.patch + # Fix build with libxml2 2.13+. Has to be applied after libxml2 2.12 patch. + (fetchpatch { + url = "https://github.com/php/php-src/commit/9b4f6b09d58a4e54ee60443bf9a8b166852c03e0.patch"; + hash = "sha256-YC3I0BQi3o3+VmRu/UqpqPpaSC+ekPqzbORTHftbPvY="; + }) + ] ++ lib.optionals (lib.versions.majorMinor php.version == "8.2" && lib.versionOlder php.version "8.2.22") [ # Fixes compatibility with libxml2 2.13. Part of 8.3.10RC1+, 8.2.22RC1+ (fetchpatch { url = "https://github.com/php/php-src/commit/4fe821311cafb18ca8bdf20b9d796c48a13ba552.diff?full_index=1"; @@ -692,7 +734,24 @@ in { "--enable-xml" ]; doCheck = false; - patches = lib.optionals (lib.versions.majorMinor php.version == "8.2" && lib.versionOlder php.version "8.2.22") [ + patches = lib.optionals (lib.versions.majorMinor php.version == "8.1") [ + # Fix tests with libxml2 2.12 + (fetchpatch { + url = "https://github.com/php/php-src/commit/061058a9b1bbd90d27d97d79aebcf2b5029767b0.patch"; + hash = "sha256-0hOlAG+pOYp/gUU0MUMZvzWpgr0ncJi5GB8IeNxxyEU="; + excludes = [ + "NEWS" + ]; + }) + # Backport of PHP_LIBXML_IGNORE_DEPRECATIONS_START and PHP_LIBXML_IGNORE_DEPRECATIONS_END + # Required for libxml2 2.13 compatibility patch. + ../development/interpreters/php/php81-fix-libxml2-2.13-compatibility.patch + # Fix build with libxml2 2.13+. Has to be applied after libxml2 2.12 patch. + (fetchpatch { + url = "https://github.com/php/php-src/commit/9b4f6b09d58a4e54ee60443bf9a8b166852c03e0.patch"; + hash = "sha256-YC3I0BQi3o3+VmRu/UqpqPpaSC+ekPqzbORTHftbPvY="; + }) + ] ++ lib.optionals (lib.versions.majorMinor php.version == "8.2" && lib.versionOlder php.version "8.2.22") [ # Fixes compatibility with libxml2 2.13. Part of 8.3.10RC1+, 8.2.22RC1+ (fetchpatch { url = "https://github.com/php/php-src/commit/4fe821311cafb18ca8bdf20b9d796c48a13ba552.diff?full_index=1"; @@ -722,7 +781,24 @@ in { configureFlags = [ "--enable-xmlwriter" ]; - patches = lib.optionals (lib.versions.majorMinor php.version == "8.2" && lib.versionOlder php.version "8.2.22") [ + patches = lib.optionals (lib.versions.majorMinor php.version == "8.1") [ + # Fix tests with libxml2 2.12 + (fetchpatch { + url = "https://github.com/php/php-src/commit/061058a9b1bbd90d27d97d79aebcf2b5029767b0.patch"; + hash = "sha256-0hOlAG+pOYp/gUU0MUMZvzWpgr0ncJi5GB8IeNxxyEU="; + excludes = [ + "NEWS" + ]; + }) + # Backport of PHP_LIBXML_IGNORE_DEPRECATIONS_START and PHP_LIBXML_IGNORE_DEPRECATIONS_END + # Required for libxml2 2.13 compatibility patch. + ../development/interpreters/php/php81-fix-libxml2-2.13-compatibility.patch + # Fix build with libxml2 2.13+. Has to be applied after libxml2 2.12 patch. + (fetchpatch { + url = "https://github.com/php/php-src/commit/9b4f6b09d58a4e54ee60443bf9a8b166852c03e0.patch"; + hash = "sha256-YC3I0BQi3o3+VmRu/UqpqPpaSC+ekPqzbORTHftbPvY="; + }) + ] ++ lib.optionals (lib.versions.majorMinor php.version == "8.2" && lib.versionOlder php.version "8.2.22") [ # Fixes compatibility with libxml2 2.13. Part of 8.3.10RC1+, 8.2.22RC1+ (fetchpatch { url = "https://github.com/php/php-src/commit/4fe821311cafb18ca8bdf20b9d796c48a13ba552.diff?full_index=1";