ext/gd: bundled libgd fails to build with FreeType < 2.10 – HAVE_FT2BUILD_H is never defined by config.m4
評価
この issue はまだ評価されていません。
説明
Description
Building PHP 8.6.0RC1 with the bundled libgd and --with-freetype fails on systems with older FreeType (e.g. 2.9.1 on RHEL/AlmaLinux/CloudLinux 8):
In file included from ext/gd/libgd/gdft.c:94:
/usr/include/freetype2/freetype/freetype.h:24:2: error: #error "`ft2build.h' hasn't been included yet!"
/usr/include/freetype2/freetype/freetype.h:25:2: error: #error "Please always use macros to include FreeType header files."
...
make: *** [Makefile:1429: ext/gd/libgd/gdft.lo] Error 1
In PHP 8.4/8.5, ext/gd/libgd/gdft.c included FreeType unconditionally:
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
In 8.6 (after the bundled libgd sync) the includes became conditional:
#ifdef HAVE_FT2BUILD_H
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include FT_SIZES_H
#else
#include <freetype/freetype.h>
#include <freetype/ftglyph.h>
#include <freetype/ftsizes.h>
#endif
However, ext/gd/config.m4 never defines HAVE_FT2BUILD_H, so on Unix builds the #else branch is always used. Direct <freetype/freetype.h> includes work with FreeType >= 2.10 (which is why the build succeeds on EL9 with FreeType 2.10.4), but FreeType 2.9.x still contains a guard in freetype.h that errors out unless ft2build.h was included first.
Note: commit f17c5ad83b67a61ec33c893c2009c0c4aeb50be7 ("Windows build: Add new function CHECK_HEADER()", #21191), which is included in PHP-8.6 and php-8.6.0RC1, also removed the implicit HAVE_FT2BUILD_H definition from the Windows build, so Windows builds may now be taking the #else branch as well.
Steps to reproduce
On an EL8-based system with freetype-devel 2.9.1:
./buildconf --force
./configure --enable-gd --with-freetype
make
Expected result: gd builds with FreeType support, as in 8.5.
Actual result: compilation of ext/gd/libgd/gdft.c fails with the errors above.
The installation fails unless you add export CPPFLAGS="${CPPFLAGS} -DHAVE_FT2BUILD_H"
Suggested fix
Define HAVE_FT2BUILD_H when FreeType is found:
--- a/ext/gd/config.m4
+++ b/ext/gd/config.m4
@@ -181,6 +181,9 @@ AC_DEFUN([PHP_GD_FREETYPE2],[
PHP_EVAL_LIBLINE([$FREETYPE2_LIBS], [GD_SHARED_LIBADD])
AC_DEFINE([HAVE_LIBFREETYPE], [1],
[Define to 1 if you have the FreeType library.])
+ AC_DEFINE([HAVE_FT2BUILD_H], [1],
+ [Define to 1 if you have the <ft2build.h> header file.])
AC_DEFINE([HAVE_GD_FREETYPE], [1],
[Define to 1 if gd extension has FreeType support.])
])
ft2build.h has been part of every FreeType 2 release, so defining it unconditionally when FreeType is enabled is safe. Alternatively, gdft.c could include <ft2build.h> unconditionally, as it did in 8.5. Adding -DHAVE_FT2BUILD_H to CPPFLAGS works around the problem.
PHP Version
PHP 8.6.0RC1
Operating System
CloudLinux 8 (RHEL 8 based), FreeType 2.9.1; builds fine on CloudLinux 9 (FreeType 2.10.4)
PHP Version
PHP 8.6.0RC1 (cli) (built: Sep 23 2026 08:57:38) (NTS)
Copyright © The PHP Group and Contributors
Zend Engine v4.6.0RC1, Copyright © Zend by Perforce
with Zend OPcache v8.6.0RC1, Copyright ©, by Zend by Perforce
Operating System
CL8
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 17時間
- マージ済み PR(30日)
- 115
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
php/php-src のほかの issue
-
Bug Status: Needs Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
Bug Status: Needs Triage
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
-
Bug Status: Needs Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
Bug Category: Tests Status: Verified
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
Bug SAPI: fpm Status: Needs Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
bradcypert/plum#53 ·
-
Component: GLib
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
Status: Opened
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
nextbsd/nextbsd-userland#285 ·