Edit report at https://bugs.php.net/bug.php?id=76324&edit=1
ID: 76324
Comment by: fred5 at originsystems dot co dot za
Reported by: eschwartz at archlinux dot org
Summary: [ext/gd] cannot detect recent versions of freetype
with pkg-config
Status: Open
Type: Bug
Package: Compile Failure
Operating System: unix-like
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
==================================================================
Output when running against 7.1.18 PHP source tree
==================================================================
patching file acinclude.m4
Hunk #9 succeeded at 889 (offset 4 lines).
Hunk #10 succeeded at 946 (offset 4 lines).
Hunk #11 succeeded at 999 (offset 11 lines).
Hunk #12 succeeded at 1029 (offset 11 lines).
Hunk #13 succeeded at 1191 (offset 11 lines).
Hunk #14 succeeded at 1256 (offset 11 lines).
Hunk #15 succeeded at 1293 (offset 11 lines).
Hunk #16 succeeded at 1315 (offset 11 lines).
Hunk #17 succeeded at 1353 (offset 11 lines).
Hunk #18 succeeded at 1374 (offset 11 lines).
Hunk #19 succeeded at 1411 (offset 11 lines).
Hunk #20 succeeded at 1514 (offset 11 lines).
Hunk #21 succeeded at 1522 (offset 11 lines).
Hunk #22 succeeded at 1629 (offset 11 lines).
Hunk #23 succeeded at 1670 (offset 11 lines).
Hunk #24 succeeded at 1716 (offset 11 lines).
Hunk #25 succeeded at 1810 (offset 11 lines).
Hunk #26 succeeded at 1847 (offset 11 lines).
Hunk #27 succeeded at 1937 (offset 11 lines).
Hunk #28 succeeded at 2012 (offset 11 lines).
Hunk #29 succeeded at 2082 (offset 11 lines).
Hunk #30 succeeded at 2119 (offset 11 lines).
Hunk #31 succeeded at 2149 (offset 11 lines).
Hunk #32 succeeded at 2183 (offset 11 lines).
Hunk #33 succeeded at 2312 (offset 5 lines).
Hunk #34 succeeded at 2359 (offset 5 lines).
Hunk #35 succeeded at 2398 (offset 5 lines).
Hunk #36 succeeded at 2433 (offset 5 lines).
Hunk #37 succeeded at 2497 (offset 5 lines).
Hunk #38 succeeded at 2531 (offset 5 lines).
Hunk #39 succeeded at 2613 (offset 5 lines).
Hunk #40 succeeded at 2624 (offset 5 lines).
Hunk #41 succeeded at 2632 (offset 5 lines).
Hunk #42 succeeded at 2655 (offset 5 lines).
Hunk #43 succeeded at 2717 (offset 5 lines).
Hunk #44 succeeded at 2785 (offset 5 lines).
Hunk #45 succeeded at 2867 (offset 5 lines).
Hunk #46 succeeded at 2877 (offset 5 lines).
Hunk #47 succeeded at 2889 (offset 5 lines).
Hunk #48 FAILED at 3317.
1 out of 48 hunks FAILED -- saving rejects to file acinclude.m4.rej
patching file pkg.m4
can't find file to patch at input line 775
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/configure.ac b/configure.ac
|index e18e1de2ef..655e06837b 100644
|--- a/configure.ac
|+++ b/configure.ac
--------------------------
File to patch:
==================================================================
Output when running against 7.2.7 PHP source tree
==================================================================
patching file acinclude.m4
Hunk #33 succeeded at 2301 (offset -6 lines).
Hunk #34 succeeded at 2348 (offset -6 lines).
Hunk #35 succeeded at 2387 (offset -6 lines).
Hunk #36 succeeded at 2422 (offset -6 lines).
Hunk #37 succeeded at 2486 (offset -6 lines).
Hunk #38 succeeded at 2520 (offset -6 lines).
Hunk #39 succeeded at 2602 (offset -6 lines).
Hunk #40 succeeded at 2613 (offset -6 lines).
Hunk #41 succeeded at 2621 (offset -6 lines).
Hunk #42 succeeded at 2644 (offset -6 lines).
Hunk #43 succeeded at 2706 (offset -6 lines).
Hunk #44 succeeded at 2774 (offset -6 lines).
Hunk #45 succeeded at 2856 (offset -6 lines).
Hunk #46 succeeded at 2866 (offset -6 lines).
Hunk #47 succeeded at 2878 (offset -6 lines).
Hunk #48 FAILED at 3317.
1 out of 48 hunks FAILED -- saving rejects to file acinclude.m4.rej
patching file pkg.m4
patching file configure.ac
Hunk #3 succeeded at 689 (offset -17 lines).
Hunk #4 succeeded at 711 (offset -17 lines).
Hunk #5 succeeded at 798 (offset -31 lines).
Hunk #6 succeeded at 808 (offset -31 lines).
Hunk #7 succeeded at 841 (offset -31 lines).
Hunk #8 succeeded at 931 (offset -31 lines).
Hunk #9 succeeded at 1029 (offset -31 lines).
Hunk #10 succeeded at 1116 (offset -31 lines).
Hunk #11 succeeded at 1235 (offset -31 lines).
can't find file to patch at input line 884
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/ext/gd/config.m4 b/ext/gd/config.m4
|index c3ff5ece24..2a9d8e3570 100644
|--- a/ext/gd/config.m4
|+++ b/ext/gd/config.m4
--------------------------
File to patch:
Previous Comments:
------------------------------------------------------------------------
[2018-07-03 20:22:21] fred5 at originsystems dot co dot za
@eshwartz - thanks for making the patch! I've tried applying it to a PHP 7.2.7 source folder as
follows:
patch < 0001-ext-gd-Use-pkg-config-to-detect-the-availability-of-freetype.patch
and it partially succeeds but sadly also returns some errors.
I'm not sure if I'm doing something wrong so would greatly appreciate any feedback.
Thanks!
------------------------------------------------------------------------
[2018-05-14 21:56:41] eschwartz at archlinux dot org
Just uploaded a patch which vendors in the pkg-config macros just like a couple autoconf-archive
blobs, and uses pkg-config to detect freetype2 support.
------------------------------------------------------------------------
[2018-05-11 02:11:28] eschwartz at archlinux dot org
Yes, it would. Users with a custom freetype directory would simply set the environment variable
PKG_CONFIG_PATH=/path/to/custom/freetype/pkgconfig/ to seamlessly override everything.
Which version to target? Well, the question is do you want to fix maintenance versions of php
fatally failing to find the requested freetype, on newer systems. Yes, people do run maintenance
versions of php even on bleeding-edge distros. This isn't something likely to fail, unless a
system simply doesn't have pkg-config.
So I'm actually looking at what it would take to do this, but I think it would be simplest to
just use standard tools like https://autotools.io/pkgconfig/pkg_check_modules.html
The entire freetype check could be replaced by:
PKG_CHECK_MODULES([FREETYPE2], [freetype2], [FREETYPE2_FOUND=true], FREETYPE2_FOUND=false)
PKG_CHECK_MODULES handles setting FREETYPE2_LIBS/FREETYPE2_CFLAGS, then lets you set custom
success/failure handlers, by default simply aborting when freetype2 is missing, in this case just
setting the FREETYPE2_FOUND variable.
Currently this doesn't find the pkg.m4 macro from the systemwide pkg-config installation, which
probably has something to do with the nonstandard acinclude.m4, buildconf setup as opposed to
autoreconf.
------------------------------------------------------------------------
[2018-05-10 21:53:23] cmb@php.net
This is related to bug #76310 â at least I presume that issue
would be resolved by switching to pkg-config. I've practically no
experience with pkg-config, so a patch or preferably a pull
request would be welcome. I'm not sure which PHP version to
target; 5.6 and 7.0 are for security fixes only, and to avoid
issues with stable versions (7.1 and 7.2) it might be best to
target master only.
------------------------------------------------------------------------
[2018-05-10 15:54:07] eschwartz at archlinux dot org
Description:
------------
To be more specific, it's using freetype-config to detect freetype, and doesn't try using
pkg-config at all.
This is wrong, as pkg-config is a comprehensive standard which should be used whenever possible, as
in fact php tries to do in other areas *before* falling back on legacy "foo-config" style
shellscripts.
This is also problematic, since https://savannah.nongnu.org/bugs/?53093 removed
the freetype-config script by default, meaning that for the current version of freetype and all
future versions it cannot be relied upon to exist.
Meanwhile, it has been available via pkg-config for approximately 15 years. Since https://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=1c513fbb8872bfac5631964963b6a751169a1ce6
freetype-config will even do its best to invoke pkg-config on your behalf (but not entirely
successfully in all cases, see the referenced bug).
There's no good reason to continue using the -config wrapper at all.
Expected result:
----------------
php versions 5.6 through 7.2 (any and all supported versions) should compile on Arch Linux with
freetype >= 2.9.1
Actual result:
--------------
No versions of php will compile, aborting with the error message:
configure: error: freetype-config not found.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76324&edit=1