<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>234622</bug_id>
          
          <creation_ts>2008-08-13 12:44 0000</creation_ts>
          <short_desc>dev-lang/lua: fix compilation it with C++ applications (needed by games-fps/edge)</short_desc>
          <delta_ts>2008-10-17 22:11:19 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Unspecified</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          <bug_file_loc>http://edge.sourceforge.net/phpBB2/viewtopic.php?p=2722#2722</bug_file_loc>
          
          
          <priority>P5</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>188214</blocked>
    
    <blocked>242170</blocked>
          
          <everconfirmed>1</everconfirmed>
          <reporter>scen@gentoo.org</reporter>
          <assigned_to>mabi@gentoo.org</assigned_to>
          <cc>galtgendo@o2.pl</cc>
    
    <cc>pchrist@gentoo.org</cc>
    
    <cc>pva@gentoo.org</cc>
    
    <cc>tarpman@gmail.com</cc>

      

      
          <long_desc isprivate="0">
            <who>scen@gentoo.org</who>
            <bug_when>2008-08-13 12:44:25 0000</bug_when>
            <thetext>Hi, here&apos;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).</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>scen@gentoo.org</who>
            <bug_when>2008-08-13 12:45:31 0000</bug_when>
            <thetext>Created an attachment (id=162816)
patch for dev-lang/lua-5.1.3-r4

</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>solar@gentoo.org</who>
            <bug_when>2008-09-13 20:28:57 0000</bug_when>
            <thetext>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.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>scen@gentoo.org</who>
            <bug_when>2008-10-09 08:12:10 0000</bug_when>
            <thetext>(In reply to comment #2)
&gt; This patch is backwords. But it should not be required. Can you explain a bit
&gt; more  why it should be built with $CHOST-g++  vs $CHOST-gcc ? Perhaps if that
&gt; is introduced so should the nocxx USE flag to keep the existing behavior.
&gt; 

I straight report the upstream&apos;s explanation:

&quot;Lua MUST be compiled with g++ and not gcc. That&apos;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).&quot;

See also here: http://edge.sourceforge.net/phpBB2/viewtopic.php?p=2722#2722</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>mabi@gentoo.org</who>
            <bug_when>2008-10-09 21:29:21 0000</bug_when>
            <thetext>I&apos;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?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>scen@gentoo.org</who>
            <bug_when>2008-10-10 07:26:26 0000</bug_when>
            <thetext>(In reply to comment #4)
&gt; I&apos;d like to introduce a cxx flag to address this situation. Compiling with gcc
&gt; is the lua upstream default and it should be kept that way.
&gt; 
&gt; Are there any objections?
&gt; 

No, it&apos;s a good solution for me.

So the edge ebuild just will need a classic &quot;built_with_use || die&quot; trick or, in the future, the great USE dependencies feature (EAPI-2).</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>mabi@gentoo.org</who>
            <bug_when>2008-10-10 08:26:29 0000</bug_when>
            <thetext>i just committed the ebuild (5.1.4-r1).

EAPI-2 is already live, so you can just say DEPEND=&quot;dev-lang/lua[cxx]&quot; :)</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>galtgendo@o2.pl</who>
            <bug_when>2008-10-10 10:25:44 0000</bug_when>
            <thetext>This seems rather strange.
Shouldn&apos;t this rather be solved by adding
extern &quot;C&quot; {...}
around lua includes in src/i_luainc.h ?
(OK, I&apos;m not sure if this would be a correct solution, 
but this seem more sane).</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>galtgendo@o2.pl</who>
            <bug_when>2008-10-10 14:01:41 0000</bug_when>
            <thetext>Consider above sort of confirmed.
I&apos;ve just tried it and edge did run afterwards.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>tarpman@gmail.com</who>
            <bug_when>2008-10-13 06:52:44 0000</bug_when>
            <thetext>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&apos;t link correctly.  Adding USE=&quot;-cxx&quot; for Lua fixed that issue, but I don&apos;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.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>galtgendo@o2.pl</who>
            <bug_when>2008-10-15 19:31:28 0000</bug_when>
            <thetext>I&apos;d say first bugs caused by this solution have hit bugzilla
(bug 242174 and bug 242170).</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>pva@gentoo.org</who>
            <bug_when>2008-10-16 19:12:01 0000</bug_when>
            <thetext>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&apos;t tested but take a look at  Rafał&apos;s suggestion (comment #7). It looks much more sane (and again read above link).</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>galtgendo@o2.pl</who>
            <bug_when>2008-10-16 22:43:52 0000</bug_when>
            <thetext>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&apos;t considered the effect of some of its design choices
for shared libs.
Of course, I don&apos;t feel as an expert on this topic,
but I&apos;d like to hear an opinion or two from such here.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>pva@gentoo.org</who>
            <bug_when>2008-10-17 07:44:27 0000</bug_when>
            <thetext>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&apos;s not supported by anybody.

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


Matti, could you revert that commit?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>mabi@gentoo.org</who>
            <bug_when>2008-10-17 22:10:13 0000</bug_when>
            <thetext>I&apos;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 &quot;extern C&quot; causes some disadvantages to exception handling it seems. While this may be a reason to compile lua with C++, as i&apos;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&apos;ve seen on the other bug, upstream is cooperative and a solution in the pipeline. Good news!</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>mabi@gentoo.org</who>
            <bug_when>2008-10-17 22:11:19 0000</bug_when>
            <thetext>Should be finally resolved, then. As the &quot;solution&quot; is the status quo, bug is marked wontfix.</thetext>
          </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>162816</attachid>
            <date>2008-08-13 12:45 0000</date>
            <desc>patch for dev-lang/lua-5.1.3-r4</desc>
            <filename>lua_with_g++.diff</filename>
            <type>text/plain</type>
            <data encoding="base64">LS0tIGx1YS01LjEuMy1yNC5lYnVpbGQJMjAwOC0wOC0xMyAxMzoxNDoxOC4wMDAwMDAwMDAgKzAy
MDAKKysrIGx1YS01LjEuMy1yNC5lYnVpbGQJMjAwOC0wOC0xMSAwMzowNTo0NC4wMDAwMDAwMDAg
KzAyMDAKQEAgLTQsNyArNCw3IEBACiAKIEVBUEk9IjEiCiAKLWluaGVyaXQgZXV0aWxzIHBvcnRh
YmlsaXR5IHRvb2xjaGFpbi1mdW5jcyB2ZXJzaW9uYXRvcgoraW5oZXJpdCBldXRpbHMgcG9ydGFi
aWxpdHkgdmVyc2lvbmF0b3IKIAogREVTQ1JJUFRJT049IkEgcG93ZXJmdWwgbGlnaHQtd2VpZ2h0
IHByb2dyYW1taW5nIGxhbmd1YWdlIGRlc2lnbmVkIGZvciBleHRlbmRpbmcgYXBwbGljYXRpb25z
IgogSE9NRVBBR0U9Imh0dHA6Ly93d3cubHVhLm9yZy8iCkBAIC03NCw3ICs3NCw2IEBACiAJCQlM
VUFfTElCUz0iJHtteWxpYnN9IiBcCiAJCQlMSUJfTElCUz0iJHtsaWJsaWJzfSIgXAogCQkJVj0k
e1BWfSBcCi0JCQlDQz0kKHRjLWdldENYWCkgXAogCQkJZ2VudG9vX2FsbCB8fCBkaWUgImVtYWtl
IGZhaWxlZCIKIAogCW12IGx1YV90ZXN0IC4uL3Rlc3QvbHVhLnN0YXRpYwo=
</data>        

          </attachment>
    </bug>

</bugzilla>