From 2f52e61a7a63ac33ef6c4761c29562056b5d8d28 Mon Sep 17 00:00:00 2001 From: Martin Schiller Date: Wed, 24 Jun 2026 12:41:05 +0200 Subject: [PATCH] lua: build: link against shared liblua ldd reports many errors regarding missing symbols because the library is not linked against liblua. root@openwrt ~ # ldd /usr/lib/lua/uci.so ldd (0x7f97830000) libuci.so.20250120 => /lib/libuci.so.20250120 (0x7f978bc000) libubox.so.20260213 => /lib/libubox.so.20260213 (0x7f9781e000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x7f977ed000) libc.so => ldd (0x7f97830000) Error relocating /usr/lib/lua/uci.so: lua_objlen: symbol not found Error relocating /usr/lib/lua/uci.so: lua_pcall: symbol not found Error relocating /usr/lib/lua/uci.so: lua_getfield: symbol not found Error relocating /usr/lib/lua/uci.so: lua_gettop: symbol not found Error relocating /usr/lib/lua/uci.so: luaL_checkstack: symbol not found Error relocating /usr/lib/lua/uci.so: luaL_checklstring: symbol not found Error relocating /usr/lib/lua/uci.so: lua_setfield: symbol not found Error relocating /usr/lib/lua/uci.so: lua_isstring: symbol not found Error relocating /usr/lib/lua/uci.so: lua_pushvalue: symbol not found Error relocating /usr/lib/lua/uci.so: lua_pushnil: symbol not found Error relocating /usr/lib/lua/uci.so: luaL_error: symbol not found Error relocating /usr/lib/lua/uci.so: lua_settop: symbol not found Error relocating /usr/lib/lua/uci.so: lua_pushcclosure: symbol not found Error relocating /usr/lib/lua/uci.so: lua_tolstring: symbol not found Error relocating /usr/lib/lua/uci.so: lua_type: symbol not found Error relocating /usr/lib/lua/uci.so: lua_pushboolean: symbol not found Error relocating /usr/lib/lua/uci.so: lua_settable: symbol not found Error relocating /usr/lib/lua/uci.so: lua_setmetatable: symbol not found Error relocating /usr/lib/lua/uci.so: lua_rawseti: symbol not found Error relocating /usr/lib/lua/uci.so: luaL_newmetatable: symbol not found Error relocating /usr/lib/lua/uci.so: lua_newuserdata: symbol not found Error relocating /usr/lib/lua/uci.so: lua_error: symbol not found Error relocating /usr/lib/lua/uci.so: lua_pushstring: symbol not found Error relocating /usr/lib/lua/uci.so: luaL_checkudata: symbol not found Error relocating /usr/lib/lua/uci.so: lua_rawgeti: symbol not found Error relocating /usr/lib/lua/uci.so: lua_toboolean: symbol not found Error relocating /usr/lib/lua/uci.so: lua_isuserdata: symbol not found Error relocating /usr/lib/lua/uci.so: lua_createtable: symbol not found Error relocating /usr/lib/lua/uci.so: lua_pushinteger: symbol not found root@openwrt ~ # Link the lua uci library against liblua, but only if it is available as a shared library. Linking the static liblua.a instead would copy the whole Lua VM into the module. In that case, e.g. in the GitHub CI, which only builds a static liblua.a, the module is linked as before. Signed-off-by: Martin Schiller --- lua/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lua/CMakeLists.txt b/lua/CMakeLists.txt index efdbfff..90b992f 100644 --- a/lua/CMakeLists.txt +++ b/lua/CMakeLists.txt @@ -36,6 +36,13 @@ SET_TARGET_PROPERTIES(uci_lua PROPERTIES ) TARGET_LINK_LIBRARIES(uci_lua uci dl) +# Only link against a shared liblua. Linking the static liblua.a would +# copy the whole Lua VM into the module. +FIND_LIBRARY(LUA_SHARED_LIBRARY NAMES liblua${CMAKE_SHARED_LIBRARY_SUFFIX}) +IF(LUA_SHARED_LIBRARY) + TARGET_LINK_LIBRARIES(uci_lua ${LUA_SHARED_LIBRARY}) +ENDIF() + INSTALL(TARGETS uci_lua LIBRARY DESTINATION ${LUAPATH} )