Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 825766

Summary: dev-lang/lua: build as C++
Product: Gentoo Linux Reporter: Alexey <alexey+gentoo>
Component: Current packagesAssignee: William Hubbs <williamh>
Status: CONFIRMED ---    
Severity: normal CC: alexey+gentoo, conikost, robbat2, sam
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Alexey 2021-11-22 00:11:13 UTC
From https://www.lua.org/pil/24.3.html

> Lua uses the setjmp facility from C, which results in a mechanism similar to exception handling. (If you compile Lua with C++, it is not difficult to change the code so that it uses real exceptions instead.) 

In fact, it already uses exceptions when compiled with C++ compiler.

If Lua is compiled with C, setjmp interferes with exceptions in C++ programs which embed Lua, by "forgetting" to unwind stack and call destructors, resulting in leaks.

I don't know if USE=cxx would be enough: how does a C program which embeds Lua handle C++ exceptions which C++ Lua would throw?

Maybe existing slots need to be duplicated? E.g. have slots such as these: 5.1, 5.1cxx, 5.3, 5.3cxx, which would need to be integrated with LUA_COMPAT in some way

WDYT?
Comment 1 Alexey 2021-11-22 09:45:33 UTC
If to just unconditionally use C++ always for it, at minimum this would require switching C programs which use lua, to also use C++ linker and handle mangled names of lua functions
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-04-15 08:23:40 UTC
CCing Marecki in case he has thoughts on it as the architect of the Lua eclasses
CCing ConiKost as one of the main Lua-wranglers in ::gentoo.
Comment 3 Marek Szuba archtester gentoo-dev 2022-04-19 15:15:44 UTC
Not a fan of very nearly doubling the number of Lua targets by using separate variants for C and C++. That said, as long as the C versions remain the default (Lua is C software which just happens to have certain special properties when compiled as C++) it is up to dev-lang/lua maintainers to decide if/how they want to hack this into being.