Neopallium / llvm-lua

Automatically exported from code.google.com/p/llvm-lua
Other
152 stars 24 forks source link

lua-compiler for standalone executables do not work #12

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
helloworld.lua:
print("Hello World")

I'm trying to compile this script as a standalone application using 
lua-compiler and I get this error:

christophe@christophe-laptop:~/lua_tests$ lua-compiler helloworld.lua 
/usr/local/bin/llvm-luac -O3 -s -bc -o helloworld.bc helloworld.lua
Failed to parse embedded 'liblua_main_bc' file: Invalid bitcode signature
llvm-luac: failed to compile Lua code into LLVM bitcode.

Any idea of what might be happening?

My system info is:
christophe@christophe-laptop:~/lua_tests$ uname -a
Linux christophe-laptop 2.6.35-23-generic #41-Ubuntu SMP Wed Nov 24 10:18:49 
UTC 2010 i686 GNU/Linux

Original issue reported on code.google.com by christop...@gmail.com on 16 Dec 2010 at 4:38

GoogleCodeExporter commented 8 years ago
I can confirm this, I get exactly the same error...

The bugtracker seems pretty dead though

Original comment by 237...@gmail.com on 1 Jan 2011 at 12:35

GoogleCodeExporter commented 8 years ago
It seems that the embed LLVM bitcode containing the main loop for standalone 
applications is generated at compile time with the bin2c util (included in 
llvm-lua) into liblua_main_bc.h. The magic number of LLVM IR bitcode is 'BC' 
(0xC0DE) and liblua_main_bc.h does not contain a valid bitcode signature 
(lua_vm_ops_bc.h has a valid signature and contains 0xC0DE). 

Looking in the build dir I found liblua_main.bc and liblua_main.bc.bc. The 
first one contains a shell script and the other is the correct file with LLVM 
IR bitcode. liblua_main_bc.h is the dump from the shell script and that's the 
reason why we get the 'Invalid bitcode signature' error.

This seems to be an error in the CMake file configuration that generates 
incorrect files for LLVM bitcode.

Kind regards,

Christophe

Original comment by christop...@gmail.com on 9 Jan 2011 at 3:00

GoogleCodeExporter commented 8 years ago
Thanks for debugging this.  The problem is with llvm-ld which was the default 
command tool used by llvm-lua's CMake files to link multiple LLVM bitcodes into 
one bitcode.

You can change the LLVM_LD variable with this command:
cmake . -D LLVM_LD=llvm-link

I have changed the default value for that variable and commited the change.

Original comment by rjakabo...@gmail.com on 9 Jan 2011 at 3:30

GoogleCodeExporter commented 8 years ago
sorry that command should be:
cmake -DLLVM_LD=llvm-link .

Original comment by rjakabo...@gmail.com on 9 Jan 2011 at 3:33