Skip to content

Enable bundled GD with JPEG and FreeType configure options - #782

Merged
asgrim merged 5 commits into
php:1.6.xfrom
andr2k:gd-jpeg-freetype
Nov 11, 2026
Merged

asgrim merged 5 commits into
php:1.6.xfrom
andr2k:gd-jpeg-freetype

Conversation

@andr2k

@andr2k andr2k commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

pie install php/gd currently fails during package resolution because GD is excluded from the bundled-extension repository. This registers php/gd and builds it with the same image features as the target PHP.

pie install php/gd --force

Behaviour

  • Detected features. On Unix builds PIE reads main/php_config.h from php-config --include-dir and adds the matching configure flag for each feature the target PHP was built with:

    php_config.h define flag added
    HAVE_GD_FREETYPE --with-freetype
    HAVE_GD_JPG --with-jpeg
    HAVE_GD_XPM --with-xpm
    HAVE_GD_WEBP --with-webp
    HAVE_GD_AVIF --with-avif
  • User-supplied flags. The same five flags are declared as configure options, so they can be passed explicitly, e.g. when the header has no GD defines (the official Docker images). A flag the user passes is never duplicated, and a value form such as --with-jpeg=/opt/jpeg is left as given.

  • No header, no change. If php-config or php_config.h is unavailable, nothing is added.

  • The development libraries for every enabled feature must be installed, whether the flag was detected or passed.

  • The existing build-provider refusal and --force override are unchanged.

  • The package requires PHP 7.4+, when these configure flag names were introduced.

Implementation

  • BundledPhpExtensionsRepository: registers gd with its configure-options, and adds augmentConfigureOptionsForPhpBundledExtensions(), which applies the mapping above for php/gd only.
  • PhpBinaryPath::phpConfigHeader(): returns the contents of php_config.h, or null.
  • UnixBuild: calls the augmentation after the libdir detection, before configure.

Tests

  • Unit: the declared options; the detection matrix (all features, one feature, #undef, existing options kept first, no duplicate, user value not overridden, no header, other extension untouched); phpConfigHeader() with and without the header file.
  • End-to-end (test/end-to-end/Dockerfile): pie install --force php/gd against Alpine's and Homebrew's PHP, each first asserting the header defines HAVE_GD_FREETYPE; the Alpine target also checks the built extension loads with LD_BIND_NOW=1.
  • CI: libjpeg-dev is added to the bundled-extension job, where test/install-bundled-php-exts.php now installs php/gd with the rest.

The historical ft2build.h failure recorded in the original GD review thread does not occur in these builds. This PR does not claim to establish its original cause.

Discussion: #781.

PR submitter checklist

  • I have read CONTRIBUTING.md
  • I discussed this feature with the maintainers in #781
  • I have added appropriate tests
  • I confirm that I have the right to submit this under the project's open source licence

@asgrim asgrim self-assigned this Nov 10, 2026
@asgrim
asgrim self-requested a review November 10, 2026 22:14
@asgrim asgrim added the enhancement New feature or request label Nov 10, 2026
@asgrim asgrim added this to the 1.6.0 milestone Nov 10, 2026
@asgrim
asgrim marked this pull request as ready for review November 10, 2026 22:15

@asgrim asgrim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @andr2k - sorry it took a while to get to. I had to work out the original issue with ft2build.h being missing; it was all to do with the flags the target PHP build has; Ondrej repos for example don't have the HAVE_GD_FREETYPE flag; I added some detection to look into php_config.h to figure out the flags, and as a result add the effective --with-... configure options which is why your PR worked originally; just now it has some evidence to support the change 😁

@asgrim
asgrim merged commit 95a7252 into php:1.6.x Nov 11, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants