Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 825766 - dev-lang/lua: build as C++
Summary: dev-lang/lua: build as C++
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: William Hubbs
Depends on:
Reported: 2021-11-22 00:11 UTC by Alexey
Modified: 2022-04-19 15:15 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Alexey 2021-11-22 00:11:13 UTC

> 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

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.