package/php-lua: fix build with lua < 5.2
PATCH 1/1 package/php-lua: fix build with lua < 5.2
php-lua fails to build in buildroot 2025.08-rc3 on the following error:
in file included from [...]/usr/include/php/Zend/zend.h:32,
from [...]/usr/include/php/main/php.h:31,
from [...]/build/php-lua-2.0.7/lua.c:24:[...]/build/php-lua-2.0.7/lua.c: In function ‘php_lua_write_property’:
[...]/build/php-lua-2.0.7/lua.c:247:37:
error: ‘val’ undeclared (first use in this function); did you mean ‘zval’?
247 | lua_pushlstring(L, ZSTR_VAL(val), ZSTR_LEN(val));
| ^~~
[...]/usr/include/php/Zend/zend_string.h:66:26:
note: in definition of macro ‘ZSTR_VAL’
66 | #define ZSTR_VAL(zstr) (zstr)->val
| ^~~~
[...]/build/php-lua-2.0.7/lua.c:247:37:
note: each undeclared identifier is reported only once for each function it appears in
247 | lua_pushlstring(L, ZSTR_VAL(val), ZSTR_LEN(val));
| ^~~
[...]/usr/include/php/Zend/zend_string.h:66:26:
note: in definition of macro ‘ZSTR_VAL’
66 | #define ZSTR_VAL(zstr) (zstr)->val
| ^~~~
make[2]: *** [Makefile:214: lua.lo] Error 1
The issue triggers only if lua interpreter version is lower than 5.2. In this case, php_lua_write_property calls ZSTR_VAL on the wrong variable.
Fix php-lua build by calling ZSTR_VAL on the correct variable.
---
While this patch fixes php-lua with lua < 5.2, this would makes it yet another downstream-only patch, which is not really desirable. I will ping in the mean time the inactive upstream repositoryv to check if there is any chance that it could be updated to integrate those patches.
--- ...a.c-fix-ZSTR_VAL-usage-when-using-lua-5.2.patch | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+)
package/php-lua/0004-lua.c-fix-ZSTR_VAL-usage-when-using-lua-5.2.patch new file +38 -0
@@ -0,0 +1,38 @@ +From 7bf334832ad36d1f2976406d680b35a168ffaa91 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Alexis=20Lothor=C3=A9?= <[email protected]> +Date: Mon, 8 Sep 2025 17:20:12 +0200 +Subject: [PATCH] lua.c: fix ZSTR_VAL usage when using lua < 5.2 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When using a lua interpreter with a version lower than 5.1, the +php_lua_write_property ends up calling the ZSTR_VAL with the wrong +variable (it is expected to receive "member", a zend_string variable, +but it is "value" that is passed, which is a zval). + +Fix php-lua compatibility with interpreters < 5.2 by passing the correct +variable + +Upstream: upstream dead, custom patch +Signed-off-by: Alexis Lothoré <[email protected]> +--- + lua.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lua.c b/lua.c +index a40e5da442a4..5889bc7f83ea 100755 +--- a/lua.c ++++ b/lua.c +@@ -244,7 +244,7 @@ static zval* php_lua_write_property(zend_object *object, zend_string *member, zv + lua_State *L = php_lua_obj_from_obj(object)->L; + + #if (LUA_VERSION_NUM < 502) +- lua_pushlstring(L, ZSTR_VAL(val), ZSTR_LEN(val)); ++ lua_pushlstring(L, ZSTR_VAL(member), ZSTR_LEN(member)); + php_lua_send_zval_to_lua(L, value); + + lua_settable(L, LUA_GLOBALSINDEX); +-- +2.51.0 +
---
base-commit: 56d9d5e8f0872737fd79abf6a60e66920bb7861c
change-id: 20250908-fix_php_lua-9bf7872b25b5
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
Romain Naour via buildroot
AppliedHello Alexis, All,
Le 09/09/2025 à 09:24, Alexis Lothoré a écrit :
Quoted 26 lines
php-lua fails to build in buildroot 2025.08-rc3 on the following error:
in file included from [...]/usr/include/php/Zend/zend.h:32,
from [...]/usr/include/php/main/php.h:31, from [...]/build/php-lua-2.0.7/lua.c:24:[...]/build/php-lua-2.0.7/lua.c: In function ‘php_lua_write_property’:
[...]/build/php-lua-2.0.7/lua.c:247:37:
error: ‘val’ undeclared (first use in this function); did you mean ‘zval’?
247 |lua_pushlstring(L, ZSTR_VAL(val), ZSTR_LEN(val));
| ^~~
[...]/usr/include/php/Zend/zend_string.h:66:26:
note: in definition of macro ‘ZSTR_VAL’
66 | #defineZSTR_VAL(zstr)(zstr)->val
| ^~~~
[...]/build/php-lua-2.0.7/lua.c:247:37:
note: each undeclared identifier is reported only once for each function it appears in
247 |lua_pushlstring(L, ZSTR_VAL(val), ZSTR_LEN(val));
| ^~~
[...]/usr/include/php/Zend/zend_string.h:66:26:
note: in definition of macro ‘ZSTR_VAL’
66 | #defineZSTR_VAL(zstr)(zstr)->val
| ^~~~
make[2]: *** [Makefile:214: lua.lo] Error 1
Quoted 7 lines
The issue triggers only if lua interpreter version is lower than 5.2. In this case,
php_lua_write_propertycallsZSTR_VALon the wrong variable.Fix php-lua build by calling
ZSTR_VALon the correct variable.Suggested-by Romain Naour <[email protected]>Signed-off-by Alexis Lothoré <[email protected]>
Adding Thomas Perale in Cc for stable branches.
Applied to master, thanks.
Best regards,
Romain
Quoted 58 lines
---
While this patch fixes php-lua with lua < 5.2, this would makes it yet another downstream-only patch, which is not really desirable. I will ping in the mean time the inactive upstream repositoryv to check if there is any chance that it could be updated to integrate those patches.--- ...a.c-fix-ZSTR_VAL-usage-when-using-lua-5.2.patch | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+)package/php-lua/0004-lua.c-fix-ZSTR_VAL-usage-when-using-lua-5.2.patch new file +38
-1@@ -0,0 +1,38 @@ +From 7bf334832ad36d1f2976406d680b35a168ffaa91 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Alexis=20Lothor=C3=A9?= <[email protected]> +Date: Mon, 8 Sep 2025 17:20:12 +0200 +Subject: [PATCH] lua.c: fix ZSTR_VAL usage when using lua < 5.2 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When using a lua interpreter with a version lower than 5.1, the +php_lua_write_property ends up calling the ZSTR_VAL with the wrong +variable (it is expected to receive "member", a zend_string variable, +but it is "value" that is passed, which is a zval). + +Fix php-lua compatibility with interpreters < 5.2 by passing the correct +variable + +Upstream: upstream dead, custom patch +Signed-off-by: Alexis Lothoré <[email protected]> +--- + lua.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lua.c b/lua.c +index a40e5da442a4..5889bc7f83ea 100755 +--- a/lua.c ++++ b/lua.c +@@ -244,7 +244,7 @@ static zval* php_lua_write_property(zend_object *object, zend_string *member, zv + lua_State *L = php_lua_obj_from_obj(object)->L; + + #if (LUA_VERSION_NUM < 502) +- lua_pushlstring(L, ZSTR_VAL(val), ZSTR_LEN(val)); ++ lua_pushlstring(L, ZSTR_VAL(member), ZSTR_LEN(member)); + php_lua_send_zval_to_lua(L, value); + + lua_settable(L, LUA_GLOBALSINDEX); +-- +2.51.0 + ---base-commit:
56d9d5e8f0872737fd79abf6a60e66920bb7861c
change-id: 20250908-fix_php_lua-9bf7872b25b5
Quoted 1 line
Best regards,
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Thomas Perale via buildroot
AppliedIn reply of:
Quoted 26 lines
php-lua fails to build in buildroot 2025.08-rc3 on the following error:
in file included from [...]/usr/include/php/Zend/zend.h:32,
from [...]/usr/include/php/main/php.h:31, from [...]/build/php-lua-2.0.7/lua.c:24:[...]/build/php-lua-2.0.7/lua.c: In function ‘php_lua_write_property’:
[...]/build/php-lua-2.0.7/lua.c:247:37:
error: ‘val’ undeclared (first use in this function); did you mean ‘zval’?
247 |lua_pushlstring(L, ZSTR_VAL(val), ZSTR_LEN(val));
| ^~~
[...]/usr/include/php/Zend/zend_string.h:66:26:
note: in definition of macro ‘ZSTR_VAL’
66 | #defineZSTR_VAL(zstr)(zstr)->val
| ^~~~
[...]/build/php-lua-2.0.7/lua.c:247:37:
note: each undeclared identifier is reported only once for each function it appears in
247 |lua_pushlstring(L, ZSTR_VAL(val), ZSTR_LEN(val));
| ^~~
[...]/usr/include/php/Zend/zend_string.h:66:26:
note: in definition of macro ‘ZSTR_VAL’
66 | #defineZSTR_VAL(zstr)(zstr)->val
| ^~~~
make[2]: *** [Makefile:214: lua.lo] Error 1
Quoted 7 lines
The issue triggers only if lua interpreter version is lower than 5.2. In this case,
php_lua_write_propertycallsZSTR_VALon the wrong variable.Fix php-lua build by calling
ZSTR_VALon the correct variable.Suggested-by Romain Naour <[email protected]>Signed-off-by Alexis Lothoré <[email protected]>
Applied to 2025.02.x, 2025.05.x & 2025.08.x. Thanks
Quoted 58 lines
---
While this patch fixes php-lua with lua < 5.2, this would makes it yet another downstream-only patch, which is not really desirable. I will ping in the mean time the inactive upstream repositoryv to check if there is any chance that it could be updated to integrate those patches.--- ...a.c-fix-ZSTR_VAL-usage-when-using-lua-5.2.patch | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+)package/php-lua/0004-lua.c-fix-ZSTR_VAL-usage-when-using-lua-5.2.patch new file +38
-1@@ -0,0 +1,38 @@ +From 7bf334832ad36d1f2976406d680b35a168ffaa91 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Alexis=20Lothor=C3=A9?= <[email protected]> +Date: Mon, 8 Sep 2025 17:20:12 +0200 +Subject: [PATCH] lua.c: fix ZSTR_VAL usage when using lua < 5.2 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When using a lua interpreter with a version lower than 5.1, the +php_lua_write_property ends up calling the ZSTR_VAL with the wrong +variable (it is expected to receive "member", a zend_string variable, +but it is "value" that is passed, which is a zval). + +Fix php-lua compatibility with interpreters < 5.2 by passing the correct +variable + +Upstream: upstream dead, custom patch +Signed-off-by: Alexis Lothoré <[email protected]> +--- + lua.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lua.c b/lua.c +index a40e5da442a4..5889bc7f83ea 100755 +--- a/lua.c ++++ b/lua.c +@@ -244,7 +244,7 @@ static zval* php_lua_write_property(zend_object *object, zend_string *member, zv + lua_State *L = php_lua_obj_from_obj(object)->L; + + #if (LUA_VERSION_NUM < 502) +- lua_pushlstring(L, ZSTR_VAL(val), ZSTR_LEN(val)); ++ lua_pushlstring(L, ZSTR_VAL(member), ZSTR_LEN(member)); + php_lua_send_zval_to_lua(L, value); + + lua_settable(L, LUA_GLOBALSINDEX); +-- +2.51.0 + ---base-commit:
56d9d5e8f0872737fd79abf6a60e66920bb7861c
change-id: 20250908-fix_php_lua-9bf7872b25b5
Quoted 10 lines
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
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot