g++ - Compiling LuaJIT as C++? -


can't seem compile luajit g++ or clang++. here debug. kindly let me know if need provide more information.

$ make cc="g++" ==== building luajit 2.0.4 ==== make -c src make[1]: entering directory `/home/nutanix/thirdparty/luajit-2.0.4/src' hostcc    host/minilua.o host/minilua.c:370: error: uninitialized const ‘luao_nilobject_’ host/minilua.c:604: error: redefinition of ‘const tvalue luao_nilobject_’ host/minilua.c:370: error: ‘const tvalue luao_nilobject_’ declared here host/minilua.c:946: error: uninitialized const ‘luap_opmodes’ host/minilua.c: in function ‘void luag_typeerror(lua_state*, const tvalue*, const char*)’: host/minilua.c:2542: error: invalid conversion ‘long int’ ‘const char*’ host/minilua.c: @ global scope: host/minilua.c:2620: error: redefinition of ‘const lu_byte luap_opmodes [38]’ host/minilua.c:946: error: ‘const lu_byte luap_opmodes [38]’ declared here make[1]: *** [host/minilua.o] error 1 make[1]: leaving directory `/home/nutanix/thirdparty/luajit-2.0.4/src' make: *** [default] error 2  $ make cc="clang++" ==== building luajit 2.0.4 ==== make -c src clang: warning: treating 'c-header' input 'c++-header' when in c++ mode, behavior deprecated clang: warning: treating 'c-header' input 'c++-header' when in c++ mode, behavior deprecated clang: warning: treating 'c-header' input 'c++-header' when in c++ mode, behavior deprecated clang: warning: treating 'c-header' input 'c++-header' when in c++ mode, behavior deprecated clang: warning: treating 'c-header' input 'c++-header' when in c++ mode, behavior deprecated clang: warning: treating 'c-header' input 'c++-header' when in c++ mode, behavior deprecated clang: warning: treating 'c-header' input 'c++-header' when in c++ mode, behavior deprecated clang: warning: treating 'c-header' input 'c++-header' when in c++ mode, behavior deprecated clang: warning: treating 'c-header' input 'c++-header' when in c++ mode, behavior deprecated make[1]: entering directory `/home/nutanix/thirdparty/luajit-2.0.4/src' hostcc    host/minilua.o clang: warning: treating 'c' input 'c++' when in c++ mode, behavior deprecated host/minilua.c:370:21: error: default initialization of object of const type       'const tvalue' (aka 'const lua_tvalue') without user-provided default       constructor static const tvalue luao_nilobject_;                     ^ host/minilua.c:370:36: note: add explicit initializer initialize 'luao_nilobject_' static const tvalue luao_nilobject_;                                    ^                                     = {} host/minilua.c:604:21: error: redefinition of 'luao_nilobject_' static const tvalue luao_nilobject_={{null},0};                     ^ host/minilua.c:370:21: note: previous definition here static const tvalue luao_nilobject_;                     ^ host/minilua.c:946:22: error: default initialization of object of const type       'const lu_byte [38]' static const lu_byte luap_opmodes[(cast(int,op_vararg)+1)];                      ^ host/minilua.c:946:59: note: add explicit initializer initialize 'luap_opmodes' static const lu_byte luap_opmodes[(cast(int,op_vararg)+1)];                                                           ^ host/minilua.c:2491:13: error: assigning 'const char *' incompatible type 'long' ar->namewhat=(ci)?null:null;             ^~~~~~~~~~~~~~~ host/minilua.c:2540:12: error: cannot initialize variable of type 'const char *'       rvalue of type 'long' const char*kind=(isinstack(l->ci,o))?            ^    ~~~~~~~~~~~~~~~~~~~~~ host/minilua.c:2620:22: error: redefinition of 'luap_opmodes' static const lu_byte luap_opmodes[(cast(int,op_vararg)+1)]={                      ^ host/minilua.c:946:22: note: previous definition here static const lu_byte luap_opmodes[(cast(int,op_vararg)+1)];                      ^ 6 errors generated. make[1]: *** [host/minilua.o] error 1 make[1]: leaving directory `/home/nutanix/thirdparty/luajit-2.0.4/src' make: *** [default] error 2  $ clang++ -v clang version 3.6.1 (tags/release_361/final) target: x86_64-redhat-linux-gnu thread model: posix found candidate gcc installation: /opt/rh/devtoolset-3/root/usr/lib/gcc/x86_64-redhat-linux/4.9.2 selected gcc installation: /opt/rh/devtoolset-3/root/usr/lib/gcc/x86_64-redhat-linux/4.9.2 candidate multilib: .;@m64 candidate multilib: 32;@m32 selected multilib: .;@m64  $ g++ -v using built-in specs. target: x86_64-redhat-linux configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux thread model: posix gcc version 4.4.7 20120313 (red hat 4.4.7-11) (gcc)  $ uname -a linux guo-dev 2.6.32-431.17.1.el6.x86_64 #1 smp wed may 7 23:32:49 utc 2014 x86_64 x86_64 x86_64 gnu/linux 

so basically, i'm on centos 6.5 system, g++ 4.4.7 , clang++ 3.6.1. trying compile luajit c++ compiler luajit can safely throw c++ exceptions.

any appreciated. thanks!

compiling luajit c++ compiler not solve problem of "safely throw c++ exceptions" because parts of luajit written in assembly language , because @ runtime machine code genenerated , executed dynamically if luajit's just-in-time-compiler active. therefore crucial machine code able handle c++ exceptions.

see section c++ exception interoperability @ luajit's website http://luajit.org/extensions.html#exceptions. there table explains under conditions safe throw c++ exceptions.

however questions mentions file luajit-2.0.4/src/host/minilua.c. written comment header of file:

/* heavily customized , minimized copy of lua 5.1.5. */ /* it's used build luajit. not have standard functions! */ 

so in theory should possible compile stripped down plain c lua c++ compiler. not affect luajit runtime.

if want compile plaina lua (and not luajit) c++ compiler, recommend take original lua's source code http://www.lua.org/ftp/, because minilua.c in luajit source stripped down in such way not possible compile c++ compiler without modifications, whereas original lua source code can compiled c++ compiler without bigger problems.


Comments