Files
rpi-buildroot/package/php-pecl-dbus/0002-Fix-PHP8-compatibility-for-DBUS_ZEND_HASH_GET_CURREN.patch
Alexis Lothoré b5a5b12cbb package/php-pecl-dbus: fix build with PHP8
The php-pecl-dbus encouters two build issues in both buildroot 2025.02.x
and master branch, both related to PHP8 and GCC14:

/home/alexis/src/buildroot/php/build/php-pecl-dbus-b147624d480c3353e6c700e9a2d0c6f14d853941/dbus.c:465:56:
error: assignment to ‘zend_object_get_properties_t’ {aka ‘struct
_zend_array * (*)(struct _zend_object *)’} from incompatible pointer
type ‘HashTable * (*)(zval *)’ {aka ‘struct _zend_array * (*)(struct
_zval_str
uct *)’} [-Wincompatible-pointer-types]
  465 |         dbus_object_handlers_dbus_array.get_properties =
dbus_array_get_properties;
      |                                                        ^
[...]

The build failure can be reproduced with this minimal defconfig:

BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_ENABLE_NEON=y
BR2_ARM_ENABLE_VFP=y
BR2_ARM_FPU_NEON=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_PACKAGE_PHP=y
BR2_PACKAGE_PHP_PECL_DBUS=y

This build failure is the result of two events/conditions:
- the update to PHP8 has changed the prototype for
  zend_object_read_property_t and zend_hash_get_current_key(see [1]).
  But at this time, php-dbus just generated a new warning
  (-Wincompatible-pointer-types)
- using bootlin bleeding-edge toolchain brings in GCC14, which now turns
  this warning into a systematic error (see [2])

Bring the relevant patches to fix this build.

The first patch comes from an already opened PR on the upstream source.
The second patch has been written during the build failure
investigation, and has been sent upstream as well.

Fixes: https://autobuild.buildroot.net/results/e9892bbefa781b403fd3d834b6c48527c8e078ba
Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
Signed-off-by: Romain Naour <romain.naour@smile.fr>
(cherry picked from commit 0ae37b712f)
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
2025-08-14 09:26:31 +02:00

52 lines
2.5 KiB
Diff

From 46a6aa1308b32549625fd7bc265ad011091b3992 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alexis=20Lothor=C3=A9?= <alexis.lothore@bootlin.com>
Date: Tue, 1 Jul 2025 17:12:32 +0200
Subject: [PATCH] Fix PHP8 compatibility for
DBUS_ZEND_HASH_GET_CURRENT_KEY_INFO
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
php-pecl-dbus currently does not build with PHP8 because of the
following error:
In file included from dbus.c:27:
dbus.c: In function 'dbus_append_var_dict':
php_dbus.h:108:64: error: passing argument 3 of 'zend_hash_get_current_key' from incompatible pointer type [-Wincompatible-pointer-types]
108 | _info.type = zend_hash_get_current_key(_ht, &tmp_info, &_idx); \
dbus.c:1295:17: note: in expansion of macro 'DBUS_ZEND_HASH_GET_CURRENT_KEY_INFO'
1295 | DBUS_ZEND_HASH_GET_CURRENT_KEY_INFO(Z_ARRVAL_P(obj->elements), num_index, key);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../host/arm-buildroot-linux-gnueabihf/sysroot/usr/include/php/Zend/zend.h:33,
from ../../host/arm-buildroot-linux-gnueabihf/sysroot/usr/include/php/main/php.h:31,
from dbus.c:21:
../../host/arm-buildroot-linux-gnueabihf/sysroot/usr/include/php/Zend/zend_hash.h:269:115: note: expected 'zend_ulong *' {aka 'unsigned int *'} but argument is of type 'ulong *' {aka 'long unsigned int *'}
269 | static zend_always_inline int zend_hash_get_current_key(const HashTable *ht, zend_string **str_index, zend_ulong *num_index) {
| ~~~~~~~~~~~~^~~~~~~~~
Fix the build error by explicitely casting the passed index pointer to
(zend_ulong *)
Upstream: https://github.com/derickr/pecl-dbus/pull/15
Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
---
php_dbus.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/php_dbus.h b/php_dbus.h
index a080159c407d..68aec7bc3c42 100644
--- a/php_dbus.h
+++ b/php_dbus.h
@@ -105,7 +105,7 @@
# define DBUS_ZEND_HASH_GET_CURRENT_KEY_INFO(_ht, _idx, _info) \
do { \
zend_string *tmp_info = NULL; \
- _info.type = zend_hash_get_current_key(_ht, &tmp_info, &_idx); \
+ _info.type = zend_hash_get_current_key(_ht, &tmp_info, (zend_ulong *)&_idx); \
if (tmp_info) { \
_info.name = ZSTR_VAL(tmp_info); \
_info.length = ZSTR_LEN(tmp_info); \
--
2.50.0