Skip to contentSkip to conversation

package/php-lua: fix build with PHP8/GCC14

PATCH Superseded Alexis Lothoré via buildroot 1 participant 5 messages Aug 6, 2025 – Aug 13, 2025

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 package/php-lua: fix build with PHP8/GCC14

On both Buildroot 2025.02.x and master branch, php-lua build fails on the following error:

lua.c:862:44: error: assignment to 'zend_object_write_property_t' {aka 'struct _zval_struct * (*)(struct _zend_object *, struct _zend_string *, struct _zval_struct *, void **)'} from incompatible pointer type 'void (*)(zval *, zval *, zval *, void **)' {aka 'void (*)(struct _zval_struct *, struct _zval_struct *, struct _zval_struct *, void **)'} [-Wincompatible-pointer-types]
862 | lua_object_handlers.write_property =
php_lua_write_property;
| ^
lua.c:863:44: error: assignment to 'zend_object_read_property_t' {aka 'struct _zval_struct * (*)(struct _zend_object *, struct _zend_string *, int, void **, struct _zval_struct *)'} from incompatible pointer type 'zval * (*)(zval *, zval *, int, void **, zval *)' {aka 'struct _zval_struct * (*)(struct _zval_struct *, struct _zval_struct *, int, void **, struct _zval_struct *)'} [-Wincompatible-pointer-types]
863 | lua_object_handlers.read_property =
php_lua_read_property;
| ^
make[2]: *** [Makefile:214: lua.lo] Error 1

The error can be reproduced with the following 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_LUA=y
BR2_PACKAGE_PHP=y
BR2_PACKAGE_PHP_LUA=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 (see [1]). But at this time, php-lua 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])

This issue is still present on the upstream repository, but it has been fixed on one of its forks. Bring the relevant patch from the fork to allow building php-lua.

[1] https://github.com/php/php-src/commit/91ef4124e56
[2] https://gcc.gnu.org/gcc-14/porting_to.html#incompatible-pointer-types

---
Changes in v2:
- update commit title
- add more details about the conditions leading to the build failure
- add minimal defconfig
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 ...-write-properly-read-property-was-changed.patch | 77 ++++++++++++++++++++++
 1 file changed, 77 insertions(+)
package/php-lua/0003-php8-Signature-of-write-properly-read-property-was-changed.patch new file +77 -0
new file mode 100644
index 0000000000000000000000000000000000000000..0c68a7062451d40a2d630c24244ab003bdfb9396
@@ -0,0 +1,77 @@
+From de1068d634519abf2461dac9427b5ff24b6603af Mon Sep 17 00:00:00 2001
+From: Mikhail Galanin <[email protected]>
+Date: Tue, 24 Aug 2021 08:28:47 +0100
+Subject: [PATCH] php8: Signature of write_property/read_property was changed
+ in https://github.com/php/php-src/commit/91ef4124e56
+
+Taken from https://github.com/badoo/php-lua/pull/8
+Signed-off-by: Alexis Lothoré <[email protected]>
+---
+ lua.c | 28 ++++++++++++++--------------
+ 1 file changed, 14 insertions(+), 14 deletions(-)
+
+diff --git a/lua.c b/lua.c
+index edc2868..32c1471 100755
+--- a/lua.c
++++ b/lua.c
+@@ -229,46 +229,46 @@ zend_object *php_lua_create_object(zend_class_entry *ce)
+ 
+ /** {{{ static zval * php_lua_read_property(zval *object, zval *member, int type)
+ */
+-zval *php_lua_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv){
+-	lua_State *L = (Z_LUAVAL_P(object))->L;
+-	zend_string *str_member;
++zval *php_lua_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv){
++	lua_State *L = php_lua_obj_from_obj(object)->L;
+ 
+ 	if (type != BP_VAR_R) {
+ 		ZVAL_NULL(rv);
+ 		return rv;
+ 	}
+ 
+-	str_member = zval_get_string(member);
+ #if (LUA_VERSION_NUM < 502)
+-	lua_getfield(L, LUA_GLOBALSINDEX, ZSTR_VAL(str_member));
++	lua_getfield(L, LUA_GLOBALSINDEX, ZSTR_VAL(member));
+ #else
+-	lua_getglobal(L, ZSTR_VAL(str_member));
++	lua_getglobal(L, ZSTR_VAL(member));
+ #endif
+-	zend_string_release(str_member);
+ 
+-	php_lua_get_zval_from_lua(L, -1, object, rv);
++	zval lua_zval_object;
++	ZVAL_OBJ(&lua_zval_object, object);
++
++	php_lua_get_zval_from_lua(L, -1, &lua_zval_object, rv);
+ 	lua_pop(L, 1);
++
+ 	return rv;
+ }
+ /* }}} */
+ 
+ /** {{{ static void php_lua_write_property(zval *object, zval *member, zval *value)
+ */
+-static void php_lua_write_property(zval *object, zval *member, zval *value, void ** key) {
+-	lua_State *L = (Z_LUAVAL_P(object))->L;
+-	zend_string *str_member = zval_get_string(member);
++static zval* php_lua_write_property(zend_object *object, zend_string *member, zval *value, void ** key) {
++	lua_State *L = php_lua_obj_from_obj(object)->L;
+ 
+ #if (LUA_VERSION_NUM < 502)
+-	php_lua_send_zval_to_lua(L, member);
++	lua_pushlstring(L, ZSTR_VAL(val), ZSTR_LEN(val));
+ 	php_lua_send_zval_to_lua(L, value);
+ 
+ 	lua_settable(L, LUA_GLOBALSINDEX);
+ #else
+ 	php_lua_send_zval_to_lua(L, value);
+-	lua_setglobal(L, Z_STRVAL_P(member));
++	lua_setglobal(L, ZSTR_VAL(member));
+ #endif
+ 
+-	zend_string_release(str_member);
++	return value;
+ }
+ /* }}} */
+ 

---
base-commit: 2fd520c8d52b9e0ed5e26343813fdd8dbcadb45f
change-id: 20250806-php-lua-39895d4fe179

Best regards,

Signature · 8 lines
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Hello Alexis, All,

Le 06/08/2025 à 22:42, Alexis Lothoré via buildroot a écrit :

Quoted 67 lines

On both Buildroot 2025.02.x and master branch, php-lua build fails on the following error:

lua.c:862:44: error: assignment to 'zend_object_write_property_t' {aka 'struct _zval_struct * (*)(struct _zend_object *, struct _zend_string *, struct _zval_struct *, void **)'} from incompatible pointer type 'void (*)(zval *, zval *, zval *, void **)' {aka 'void (*)(struct _zval_struct *, struct _zval_struct *, struct _zval_struct *, void **)'} [-Wincompatible-pointer-types]
862 | lua_object_handlers.write_property =
php_lua_write_property;
| ^
lua.c:863:44: error: assignment to 'zend_object_read_property_t' {aka 'struct _zval_struct * (*)(struct _zend_object *, struct _zend_string *, int, void **, struct _zval_struct *)'} from incompatible pointer type 'zval * (*)(zval *, zval *, int, void **, zval *)' {aka 'struct _zval_struct * (*)(struct _zval_struct *, struct _zval_struct *, int, void **, struct _zval_struct *)'} [-Wincompatible-pointer-types]
863 | lua_object_handlers.read_property =
php_lua_read_property;
| ^
make[2]: *** [Makefile:214: lua.lo] Error 1

The error can be reproduced with the following 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_LUA=y
BR2_PACKAGE_PHP=y
BR2_PACKAGE_PHP_LUA=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 (see [1]). But at this time, php-lua 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])

This issue is still present on the upstream repository, but it has been fixed on one of its forks. Bring the relevant patch from the fork to allow building php-lua.

[1] https://github.com/php/php-src/commit/91ef4124e56
[2] https://gcc.gnu.org/gcc-14/porting_to.html#incompatible-pointer-types

---
Changes in v2:
- update commit title
- add more details about the conditions leading to the build failure
- add minimal defconfig
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 ...-write-properly-read-property-was-changed.patch | 77 ++++++++++++++++++++++
 1 file changed, 77 insertions(+)
package/php-lua/0003-php8-Signature-of-write-properly-read-property-was-changed.patch new file +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..0c68a7062451d40a2d630c24244ab003bdfb9396

package/php-lua/0003-php8-Signature-of-write-properly-read-property-was-changed.patch line 7

Quoted 7 lines
package/php-lua/0003-php8-Signature-of-write-properly-read-property-was-changed.patch new file +7 -0
@@ -0,0 +1,77 @@
+From de1068d634519abf2461dac9427b5ff24b6603af Mon Sep 17 00:00:00 2001
+From: Mikhail Galanin <[email protected]>
+Date: Tue, 24 Aug 2021 08:28:47 +0100
+Subject: [PATCH] php8: Signature of write_property/read_property was changed
+ in https://github.com/php/php-src/commit/91ef4124e56
+
+Taken from https://github.com/badoo/php-lua/pull/8

Check-package warn about missing "Upstream:" link.

Since the patch come from a fork, using "Upstream" looks wrong here. Maybe Upstream: n/a ?

Best regards,
Romain

Quoted 75 lines
package/php-lua/0003-php8-Signature-of-write-properly-read-property-was-changed.patch new file +70 -1
+Signed-off-by: Alexis Lothoré <[email protected]>
+---
+ lua.c | 28 ++++++++++++++--------------
+ 1 file changed, 14 insertions(+), 14 deletions(-)
+
+diff --git a/lua.c b/lua.c
+index edc2868..32c1471 100755
+--- a/lua.c
++++ b/lua.c
+@@ -229,46 +229,46 @@ zend_object *php_lua_create_object(zend_class_entry *ce)
+ 
+ /** {{{ static zval * php_lua_read_property(zval *object, zval *member, int type)
+ */
+-zval *php_lua_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv){
+-	lua_State *L = (Z_LUAVAL_P(object))->L;
+-	zend_string *str_member;
++zval *php_lua_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv){
++	lua_State *L = php_lua_obj_from_obj(object)->L;
+ 
+ 	if (type != BP_VAR_R) {
+ 		ZVAL_NULL(rv);
+ 		return rv;
+ 	}
+ 
+-	str_member = zval_get_string(member);
+ #if (LUA_VERSION_NUM < 502)
+-	lua_getfield(L, LUA_GLOBALSINDEX, ZSTR_VAL(str_member));
++	lua_getfield(L, LUA_GLOBALSINDEX, ZSTR_VAL(member));
+ #else
+-	lua_getglobal(L, ZSTR_VAL(str_member));
++	lua_getglobal(L, ZSTR_VAL(member));
+ #endif
+-	zend_string_release(str_member);
+ 
+-	php_lua_get_zval_from_lua(L, -1, object, rv);
++	zval lua_zval_object;
++	ZVAL_OBJ(&lua_zval_object, object);
++
++	php_lua_get_zval_from_lua(L, -1, &lua_zval_object, rv);
+ 	lua_pop(L, 1);
++
+ 	return rv;
+ }
+ /* }}} */
+ 
+ /** {{{ static void php_lua_write_property(zval *object, zval *member, zval *value)
+ */
+-static void php_lua_write_property(zval *object, zval *member, zval *value, void ** key) {
+-	lua_State *L = (Z_LUAVAL_P(object))->L;
+-	zend_string *str_member = zval_get_string(member);
++static zval* php_lua_write_property(zend_object *object, zend_string *member, zval *value, void ** key) {
++	lua_State *L = php_lua_obj_from_obj(object)->L;
+ 
+ #if (LUA_VERSION_NUM < 502)
+-	php_lua_send_zval_to_lua(L, member);
++	lua_pushlstring(L, ZSTR_VAL(val), ZSTR_LEN(val));
+ 	php_lua_send_zval_to_lua(L, value);
+ 
+ 	lua_settable(L, LUA_GLOBALSINDEX);
+ #else
+ 	php_lua_send_zval_to_lua(L, value);
+-	lua_setglobal(L, Z_STRVAL_P(member));
++	lua_setglobal(L, ZSTR_VAL(member));
+ #endif
+ 
+-	zend_string_release(str_member);
++	return value;
+ }
+ /* }}} */
+ 
 
---

base-commit: 2fd520c8d52b9e0ed5e26343813fdd8dbcadb45f
change-id: 20250806-php-lua-39895d4fe179

Quoted 1 line

Best regards,

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw

Hi Romain,

Quoted 3 lines · Romain Naour via buildroot

Hello Alexis, All,

Le 06/08/2025 à 22:42, Alexis Lothoré via buildroot a écrit :

[...]

Quoted 16 lines

package/php-lua/0003-php8-Signature-of-write-properly-read-property-was-changed.patch line 7

Quoted 13 lines
package/php-lua/0003-php8-Signature-of-write-properly-read-property-was-changed.patch new file +7 -0
new file mode 100644
index 0000000000000000000000000000000000000000..0c68a7062451d40a2d630c24244ab003bdfb9396
@@ -0,0 +1,77 @@
+From de1068d634519abf2461dac9427b5ff24b6603af Mon Sep 17 00:00:00 2001
+From: Mikhail Galanin <[email protected]>
+Date: Tue, 24 Aug 2021 08:28:47 +0100
+Subject: [PATCH] php8: Signature of write_property/read_property was changed
+ in https://github.com/php/php-src/commit/91ef4124e56
+
+Taken from https://github.com/badoo/php-lua/pull/8

Check-package warn about missing "Upstream:" link.

Quoted 2 lines

Since the patch come from a fork, using "Upstream" looks wrong here. Maybe Upstream: n/a ?

Sure, I can add this empty Upstream in the next revision.

Alexis

Quoted 4 lines

Best regards,
Romain

Signature · 8 lines
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw
Quoted 6 lines · On Mon, 11 Aug 2025 07:24:07 +0200 Alexis Lothoré <[email protected]>…
Quoted 4 lines

Check-package warn about missing "Upstream:" link.

Since the patch come from a fork, using "Upstream" looks wrong here. Maybe Upstream: n/a ?

Sure, I can add this empty Upstream in the next revision.

I don't think "Upstream: n/a" is very useful.

In fact, something like:

Upstream: upstream dead, taken from fork at https://github.com/badoo/php-lua/pull/8

is IMO a lot more useful.

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw

Hi,

Quoted 10 lines · Thomas Petazzoni via buildroot
Quoted 6 lines · On Mon, 11 Aug 2025 07:24:07 +0200 Alexis Lothoré <[email protected]>…
Quoted 4 lines

Check-package warn about missing "Upstream:" link.

Since the patch come from a fork, using "Upstream" looks wrong here. Maybe Upstream: n/a ?

Sure, I can add this empty Upstream in the next revision.

Quoted 7 lines

I don't think "Upstream: n/a" is very useful.

In fact, something like:

Upstream: upstream dead, taken from fork at https://github.com/badoo/php-lua/pull/8

is IMO a lot more useful.

Sure, I can update set something like this. But just to re-clarify, the fork isn't really alive neither. It has just been dead for... less longer. I'll wait a bit before re-spinning in case anyone else comes with another opinion.

Quoted 2 lines

Thomas

Signature · 8 lines
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot