Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 234622 - dev-lang/lua: fix compilation it with C++ applications (needed by games-fps/edge)
Summary: dev-lang/lua: fix compilation it with C++ applications (needed by games-fps/e...
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All Linux
: Lowest normal (vote)
Assignee: Matti Bickel (RETIRED)
URL: http://edge.sourceforge.net/phpBB2/vi...
Whiteboard:
Keywords:
Depends on:
Blocks: 188214 242170
  Show dependency tree
 
Reported: 2008-08-13 12:44 UTC by Davide Cendron (RETIRED)
Modified: 2008-10-17 22:11 UTC (History)
4 users (show)

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


Attachments
patch for dev-lang/lua-5.1.3-r4 (lua_with_g++.diff,557 bytes, patch)
2008-08-13 12:45 UTC, Davide Cendron (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Davide Cendron (RETIRED) gentoo-dev 2008-08-13 12:44:25 UTC
Hi, here's a trivial patch for compiling dev-lang/lua with g++ instead of gcc.

It solves some trouble with some package, e.g. games-fps/edge (see bug #188214).
Comment 1 Davide Cendron (RETIRED) gentoo-dev 2008-08-13 12:45:31 UTC
Created attachment 162816 [details, diff]
patch for dev-lang/lua-5.1.3-r4
Comment 2 solar (RETIRED) gentoo-dev 2008-09-13 20:28:57 UTC
This patch is backwords. But it should not be required. Can you explain a bit more  why it should be built with $CHOST-g++  vs $CHOST-gcc ? Perhaps if that is introduced so should the nocxx USE flag to keep the existing behavior.
Comment 3 Davide Cendron (RETIRED) gentoo-dev 2008-10-09 08:12:10 UTC
(In reply to comment #2)
> This patch is backwords. But it should not be required. Can you explain a bit
> more  why it should be built with $CHOST-g++  vs $CHOST-gcc ? Perhaps if that
> is introduced so should the nocxx USE flag to keep the existing behavior.
> 

I straight report the upstream's explanation:

"Lua MUST be compiled with g++ and not gcc. That's because it needs to use special C++ exception stuff for handling errors properly.

That explains your missing symbols, the linker is looking for C++ mangled symbol names instead of normal C symbol names (or vice versa)."

See also here: http://edge.sourceforge.net/phpBB2/viewtopic.php?p=2722#2722
Comment 4 Matti Bickel (RETIRED) gentoo-dev 2008-10-09 21:29:21 UTC
I'd like to introduce a cxx flag to address this situation. Compiling with gcc is the lua upstream default and it should be kept that way.

Are there any objections?
Comment 5 Davide Cendron (RETIRED) gentoo-dev 2008-10-10 07:26:26 UTC
(In reply to comment #4)
> I'd like to introduce a cxx flag to address this situation. Compiling with gcc
> is the lua upstream default and it should be kept that way.
> 
> Are there any objections?
> 

No, it's a good solution for me.

So the edge ebuild just will need a classic "built_with_use || die" trick or, in the future, the great USE dependencies feature (EAPI-2).
Comment 6 Matti Bickel (RETIRED) gentoo-dev 2008-10-10 08:26:29 UTC
i just committed the ebuild (5.1.4-r1).

EAPI-2 is already live, so you can just say DEPEND="dev-lang/lua[cxx]" :)
Comment 7 Rafał Mużyło 2008-10-10 10:25:44 UTC
This seems rather strange.
Shouldn't this rather be solved by adding
extern "C" {...}
around lua includes in src/i_luainc.h ?
(OK, I'm not sure if this would be a correct solution, 
but this seem more sane).
Comment 8 Rafał Mużyło 2008-10-10 14:01:41 UTC
Consider above sort of confirmed.
I've just tried it and edge did run afterwards.
Comment 9 Ryan Tandy 2008-10-13 06:52:44 UTC
This seems weird to me.  Now if Lua is built with g++, my programs that link against it also have to be built with g++, or they don't link correctly.  Adding USE="-cxx" for Lua fixed that issue, but I don't have a very hard time imagining that sooner or later we will have one package in the tree that needs lua built with g++ and another that needs it built with gcc, which would prevent them from being installed at the same time.  I agree with Rafał that this should be addressed with some more portable fix.
Comment 10 Rafał Mużyło 2008-10-15 19:31:28 UTC
I'd say first bugs caused by this solution have hit bugzilla
(bug 242174 and bug 242170).
Comment 11 Peter Volkov (RETIRED) gentoo-dev 2008-10-16 19:12:01 UTC
I think this fix should be reconsidered as it breaks packages. Lua is C application and should be compiled with C compiler only! Please, explain in little more details what exceptions C code of lua starts to use when it is compiled with g++?

Missing symbols are quite understandable as g++ mangle symbols. Read about that here:

http://en.wikipedia.org/wiki/Name_mangling#Handling_of_C_symbols_when_linking_from_C.2B.2B

Currently I consider what was added to the tree as very nasty hack. Please revert.

I haven't tested but take a look at  Rafał's suggestion (comment #7). It looks much more sane (and again read above link).
Comment 12 Rafał Mużyło 2008-10-16 22:43:52 UTC
I think main problem here lies in the lua upstream (as I wrote in
bug 242170#c4).
Lua was designed to be too embeddable - upstream was so focused on static linking,
that it hasn't considered the effect of some of its design choices
for shared libs.
Of course, I don't feel as an expert on this topic,
but I'd like to hear an opinion or two from such here.
Comment 13 Peter Volkov (RETIRED) gentoo-dev 2008-10-17 07:44:27 UTC
Since there are ways to use lua in C++ code (see my comment in edge bug) I think current problem lays in edge upstream. They should provide correct solution...

Having system lua being built with C++ should be removed is it's not supported by anybody.

And speaking about extern "C". lua provides lua.hpp for this exact case, but although this'll possibly fix compilation this'll break error handling. And error handling should be fixed by upstream...


Matti, could you revert that commit?
Comment 14 Matti Bickel (RETIRED) gentoo-dev 2008-10-17 22:10:13 UTC
I've done so, and pulled the lua-5.1.4-r1 ebuild from the tree.
sorry for the confusion it caused.

Well, compiling lua with "extern C" causes some disadvantages to exception handling it seems. While this may be a reason to compile lua with C++, as i've written in the changelog entry, the benefits of doing this systemwide are much lower than the disadvantages (other packages breaking, etc.)

Thus i think the burden really is on edge upstream. As i've seen on the other bug, upstream is cooperative and a solution in the pipeline. Good news!
Comment 15 Matti Bickel (RETIRED) gentoo-dev 2008-10-17 22:11:19 UTC
Should be finally resolved, then. As the "solution" is the status quo, bug is marked wontfix.