From c96ed68430cbe526f2a38ace6f7be42e8cd4532c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20Lothor=C3=A9?= Date: Tue, 9 Sep 2025 09:24:19 +0200 Subject: [PATCH] package/php-lua: fix build with lua < 5.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Fixes: https://gitlab.com/buildroot.org/buildroot/-/jobs/11271124501 (TestPhpLuaLuajit) Suggested-by: Romain Naour Signed-off-by: Alexis Lothoré [Romain: add link to failing TestPhpLuaLuajit] Signed-off-by: Romain Naour (cherry picked from commit a1daf153bf962d1797598943f8c8709ed04e4642) Signed-off-by: Thomas Perale --- ...ix-ZSTR_VAL-usage-when-using-lua-5.2.patch | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 package/php-lua/0004-lua.c-fix-ZSTR_VAL-usage-when-using-lua-5.2.patch diff --git a/package/php-lua/0004-lua.c-fix-ZSTR_VAL-usage-when-using-lua-5.2.patch b/package/php-lua/0004-lua.c-fix-ZSTR_VAL-usage-when-using-lua-5.2.patch new file mode 100644 index 0000000000..c5d99db7f5 --- /dev/null +++ b/package/php-lua/0004-lua.c-fix-ZSTR_VAL-usage-when-using-lua-5.2.patch @@ -0,0 +1,38 @@ +From 7bf334832ad36d1f2976406d680b35a168ffaa91 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Alexis=20Lothor=C3=A9?= +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é +--- + 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 +