From: Vsevolod Stakhov Date: Fri, 10 Jul 2026 07:38:03 +0000 (+0100) Subject: [Fix] rspamd_symcache.h: keep C linkage of lua.h for C++ includers X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F6126%2Fhead;p=thirdparty%2Frspamd.git [Fix] rspamd_symcache.h: keep C linkage of lua.h for C++ includers The raw lua.h include sat outside extern "C", so any C++ unit that pulled rspamd_symcache.h before lua/lua_common.h got C++-mangled declarations of the Lua C API and failed to link. Including lua_common.h itself is not an option due to the include cycle via rspamd.h -> cfg_file.h -> rspamd_symcache.h, so wrap lua.h the same way lua_common.h does. This also lets composites sources include lua_common.h in the natural position instead of first. --- diff --git a/src/libserver/composites/composites.cxx b/src/libserver/composites/composites.cxx index 6c69c0cc88..da0546f2bd 100644 --- a/src/libserver/composites/composites.cxx +++ b/src/libserver/composites/composites.cxx @@ -14,9 +14,6 @@ * limitations under the License. */ #include "config.h" -/* Must go first to keep the C linkage of the raw lua headers */ -#include "lua/lua_common.h" - #include "logger.h" #include "expression.h" #include "task.h" @@ -25,6 +22,7 @@ #include "composites.h" #include "contrib/libev/ev.h" #include "libutil/util.h" +#include "lua/lua_common.h" #include #include diff --git a/src/libserver/composites/composites_manager.cxx b/src/libserver/composites/composites_manager.cxx index 9f3628d8b4..a1b1375443 100644 --- a/src/libserver/composites/composites_manager.cxx +++ b/src/libserver/composites/composites_manager.cxx @@ -14,9 +14,6 @@ * limitations under the License. */ -/* Must go first to keep the C linkage of the raw lua headers */ -#include "lua/lua_common.h" - #include #include #include @@ -29,6 +26,7 @@ #include "libserver/maps/map.h" #include "libserver/rspamd_symcache.h" #include "libutil/cxx/util.hxx" +#include "lua/lua_common.h" namespace rspamd::composites { diff --git a/src/libserver/rspamd_symcache.h b/src/libserver/rspamd_symcache.h index 1ae33bd294..efbb327799 100644 --- a/src/libserver/rspamd_symcache.h +++ b/src/libserver/rspamd_symcache.h @@ -21,7 +21,16 @@ #include "cfg_file.h" #include "contrib/libev/ev.h" +/* Lua headers do not have __cplusplus guards, so keep their C linkage + * explicitly; including lua_common.h here is not an option as it creates + * an include cycle via rspamd.h -> cfg_file.h -> rspamd_symcache.h */ +#ifdef __cplusplus +extern "C" { +#endif #include +#ifdef __cplusplus +} +#endif #ifdef __cplusplus extern "C" {