From 024243bac4612c62ef5be676818ed2465edae27f Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sun, 23 May 2021 00:10:02 +0200 Subject: [PATCH] php74.extensions.iconv: fix error signalling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The configure script checks whether iconv supports errno. Unfortunately, on PHP < 8, the test program includes $PHP_ICONV_H_PATH, which defaults to FHS path so it fails to build: conftest.c:13:10: fatal error: /usr/include/iconv.h: No such file or directory 13 | #include | ^~~~~~~~~~~~~~~~~~~~~~ That causes the feature check to report a false negative, leading PHP to use a degraded code that returns PHP_ICONV_ERR_UNKNOWN when error occurs, breaking granular error handling in applications. To prevent this, let’s just include . PHP 8 just uses include path so the detection works there: https://github.com/php/php-src/commit/7bd1d703411e1e4b1f663f0cb06af619eea04b42 --- pkgs/top-level/php-packages.nix | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkgs/top-level/php-packages.nix b/pkgs/top-level/php-packages.nix index 6aa23a22713a..af47529f3640 100644 --- a/pkgs/top-level/php-packages.nix +++ b/pkgs/top-level/php-packages.nix @@ -322,10 +322,16 @@ lib.makeScope pkgs.newScope (self: with self; { configureFlags = [ "--with-gmp=${gmp.dev}" ]; } { name = "hash"; enable = lib.versionOlder php.version "7.4"; } { name = "iconv"; - configureFlags = if stdenv.isDarwin then - [ "--with-iconv=${libiconv}" ] - else - [ "--with-iconv" ]; + configureFlags = [ + "--with-iconv${lib.optionalString stdenv.isDarwin "=${libiconv}"}" + ]; + patches = lib.optionals (lib.versionOlder php.version "8.0") [ + # Header path defaults to FHS location, preventing the configure script from detecting errno support. + (fetchpatch { + url = "https://github.com/fossar/nix-phps/raw/263861a8c9bdafd7abe44db6db4ef0179643680c/pkgs/iconv-header-path.patch"; + sha256 = "7GHnEUu+hcsQ4h3itDwk6p46ZKfib9JZ2XpWlXrdn6E="; + }) + ]; doCheck = false; } { name = "imap"; buildInputs = [ uwimap openssl pam pcre' ];