[wrynose][meta-oe][PATCH 4/4] sysdig: Use LuaJIT headers to match the linked LuaJIT library

Anuj Mittal <[email protected]> Fri, 24 Jul 2026 06:37:46 +0530
Newsgroups org.openembedded.lists.openembedded-devel
Message-ID <[email protected]>
From: Khem Raj <[email protected]>

csysdig fails to link when stock Lua is also present in the sysroot:

  ld.lld: error: undefined symbol: luaL_openselectedlibs
  >>> referenced by chisel.cpp:1190
  ld.lld: error: undefined symbol: lua_pcallk
  ld.lld: error: undefined symbol: lua_setglobal

sysdig's chisel code does #include "lua.h" and links against LuaJIT
(lua${JIT}), but the recipe-sysroot also carries stock Lua headers
(openembedded-core lua installs lua.h into ${includedir}). Those headers
win the include search over ${includedir}/luajit-2.1, so the chisel
objects are compiled against stock Lua while the binary links
libluajit-5.1.so. In Lua >= 5.4.4 luaL_openlibs is a macro for
luaL_openselectedlibs and lua_setglobal/lua_pcallk are real symbols,
none of which LuaJIT (a Lua 5.1 ABI) provides, hence the undefined
references. -DLUA_INCLUDE_DIR does not help: sysdig's luajit.cmake only
consults it in its stock-Lua fallback, not when it finds LuaJIT.

Prepend ${STAGING_INCDIR}/luajit-2.1 to CFLAGS/CXXFLAGS. These land in
CMAKE_CXX_FLAGS, which precede CMake's generated -I includes, so LuaJIT's
lua.h is found first and matches the linked library.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Khem Raj <[email protected]>
(cherry picked from commit 00e7a9118097cbcf4677cbcfebb772357623f4cd)
Signed-off-by: Anuj Mittal <[email protected]>
---
 meta-oe/recipes-extended/sysdig/sysdig_0.39.0.bb | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/meta-oe/recipes-extended/sysdig/sysdig_0.39.0.bb b/meta-oe/recipes-extended/sysdig/sysdig_0.39.0.bb
index 6d754b9bd0..bea66ad17c 100644
--- a/meta-oe/recipes-extended/sysdig/sysdig_0.39.0.bb
+++ b/meta-oe/recipes-extended/sysdig/sysdig_0.39.0.bb
@@ -62,9 +62,18 @@ EXTRA_OECMAKE = "\
                 -DCREATE_TEST_TARGETS=OFF \
 "
 
+# sysdig's chisel code does #include "lua.h". The recipe-sysroot also carries
+# stock Lua headers (openembedded-core lua installs lua.h into ${includedir}),
+# which are ABI-incompatible with the LuaJIT library sysdig links against: in
+# Lua >= 5.4.4 luaL_openlibs is a macro for luaL_openselectedlibs and
+# lua_setglobal/lua_pcallk are real symbols, none of which LuaJIT provides.
+# sysdig's luajit.cmake only honours LUA_INCLUDE_DIR in its stock-Lua fallback,
+# not when it finds LuaJIT, and the LuaJIT include dir does not win the search
+# order, so lua.h resolves to the stock header and the link fails. Put the
+# LuaJIT include dir first so its lua.h is used and matches the linked library.
 #Add include dir to find driver_config.h
-CXXFLAGS:append = " -I${WORKDIR}/driver_Make/driver/src"
-CFLAGS:append = " -I${WORKDIR}/driver_Make/driver/src"
+CXXFLAGS:append = " -I${STAGING_INCDIR}/luajit-2.1 -I${WORKDIR}/driver_Make/driver/src"
+CFLAGS:append = " -I${STAGING_INCDIR}/luajit-2.1 -I${WORKDIR}/driver_Make/driver/src"
 
 #To fix do_package QA Issue
 do_compile:append() {
-- 
2.54.0