multiPHP pecl builds use the system php-config (fails on Rocky 10)

apnscp version

revision: 6c7081da81c9aedc2c07c67f7983ca7454b12630
timestamp: 1793634548
ver_maj: 3
ver_min: 2
ver_patch: 49
ver_pre: ''
dirty: false
checksum: 13528ef6042d85d
debug: false
os: '10.2'
variant: rocky
kernel: 6.12.0-211.69.1.el10_2.x86_64

OS
Rocky Linux release 10.2 (Red Quartz)

System PHP 8.4.27, native multiPHP 8.1, 8.2, 8.3, 8.5. cp.bootstrapper pecl_extensions is [imagick,redis].

Reproducible?
Yes, every time.

cpcmd scope:set cp.bootstrapper pecl_extensions '[imagick,redis]'
upcp -sbf php/install-extensions
upcp -sbf php/multiphp

The redis build for 8.1 fails:

/usr/include/php/Zend/zend_operators.h:221:29: error: implicit declaration of function 'memrchr'; did you mean 'memchr'? [-Wimplicit-function-declaration]
make: *** [Makefile:224: redis_array_impl.lo] Error 1

phpize comes from native/8.1, but configure gets the system php-config:

PHP Api Version:         20210902
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/main ...
checking for PHP extension directory... /usr/lib64/20240924

The 8.1 php-config itself is fine:

--prefix: /
--include-dir: //.socket/php/multiphp/native/8.1/include/php
--extension-dir: /usr/lib64/20210902

Running installPecl.sh by hand with PHPIZE and PHPCONFIG both pointed at native/8.1 builds redis fine.

Debug mode
Not applicable. It fails inside the bootstrapper, not apnscpd.

Cause
roles/apnscp/install-extensions/defaults/main.yml sets phpconfig: /usr/bin/php-config. That role is listed statically in bootstrap.yml and private role vars are off, so the default leaks into later roles.

roles/php/multiphp/tasks/build-multi.yml and roles/php/build-from-source/tasks/multiphp.yml include php/install-pecl-module with only multiphp_build: true. phpize falls back to the role default (native prefix, correct). phpconfig picks up the leaked /usr/bin/php-config. The include_vars in roles/php/install-extensions/tasks/main.yml that’s supposed to re-evaluate phpconfig is skipped because phpconfig is already set.

GCC 14 on Rocky 10 makes the implicit declaration a hard error. On EL8/9 it’s only a warning, so it has probably been building native modules against the system headers and installing them into the system extension dir there.

Proposed fix
Pass both explicitly in the two multiPHP pecl includes, the same way apnscp/install-extensions already does for the panel build:

    phpize: "{{ multiphp_php_prefix }}/bin/phpize"
    phpconfig: "{{ multiphp_php_prefix }}/bin/php-config"

Or move phpconfig in apnscp/install-extensions out of defaults/ and into the include vars so it stops leaking.

Same thing on Rocky 8.10, so it’s not just EL10. Mine fails at configure because there’s no /usr/bin/php-config on the box:

~]# cat /etc/redhat-release 
Rocky Linux release 8.10 (Green Obsidian)

~]# cpcmd misc:cp-version
revision: b08d5efe51ae62c775f56b3622463535689d1e9c
timestamp: 1793344042
ver_maj: 3
ver_min: 2
ver_patch: 49
ver_pre: ''
dirty: false
checksum: 13528f079eb7b33
debug: false
TASK [php/install-extensions : Build and install imagick library.]
fatal: [localhost]: FAILED! => {"cmd": [".../installPecl.sh", "https://pecl.php.net/get/imagick-3.8.1.tgz", ""], "rc": 1, ...}

Configuring for:
PHP Api Version:         20220829
...
configure: error: Cannot find php-config. Please use --with-php-config=PATH

Thanks for the bug report. Fixed. Removing variable reinitialization is a more straightforward approach, since that introduces unwanted side-effects.

I’ve played around with private role vars; total memory utilization is paradoxically higher when enabled.

# cat /sys/fs/cgroup/{,no-}private/memory.peak
438591488
393908224

Additionally, be careful with blanket extensions. pecl_extensions applies to all PHP versions. pecl_phpXY applies just to a specific build of PHP. Juggling old versions may pull down the latest extension that isn’t compatible with that EOL PHP release.

Literally just imagick and redis:

pecl_extensions:
- imagick
- redis

Thanks for looking into it and resolving it :smiley: